/**
 * Upsells page — same design language as the Messages hub, Guests and Tasks.
 *
 * Tokens, stage pills, filter pills and the avatar come from messaging-ui.css,
 * which this page now loads; this is the page-specific layer.
 */

/* ==========================================================================
   PAGE LAYOUT - Account for top navigation
   ========================================================================== */
body.has-top-nav .main-content {
    padding-top: calc(60px + 2rem) !important; /* 60px nav + 2rem standard padding */
    background: var(--hub-canvas);
    min-height: 100vh;
}

/* ==========================================================================
   PAGE HEADER
   ========================================================================== */
.upsells-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.upsells-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--hub-ink);
    margin: 0 0 0.1875rem;
}

.upsells-subtitle {
    font-size: 0.8125rem;
    color: var(--hub-muted);
    margin: 0;
}

/* ==========================================================================
   TABS — the hub's underline bar, on Bootstrap's tab markup
   ========================================================================== */
.upsells-tabs {
    border-bottom: 1px solid var(--hub-border);
    gap: 1.625rem;
    flex-wrap: nowrap;
    margin-bottom: 1.5rem;
}

.upsells-tabs .nav-link {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    padding: 0.8125rem 0.125rem;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 0;
    color: var(--hub-muted);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    background: transparent;
}

.upsells-tabs .nav-link:hover {
    border-bottom-color: var(--hub-line);
    color: var(--hub-ink);
}

.upsells-tabs .nav-link.active {
    background: transparent;
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

/* Sub-tabs inside Manage items, and the Past-requests status filters */
.upsells-subtabs {
    gap: 0.375rem;
}

.upsells-subtabs .nav-link,
.upsells-filter-pills .btn {
    border: 1px solid var(--hub-line);
    background: #fff;
    color: var(--hub-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
    padding: 0.40625rem 0.875rem;
    border-radius: 99px;
    white-space: nowrap;
}

.upsells-subtabs .nav-link:hover:not(.active),
.upsells-filter-pills .btn:hover:not(.active) {
    border-color: #cfd6dd;
    color: var(--hub-ink);
    background: #fff;
}

.upsells-subtabs .nav-link.active,
.upsells-filter-pills .btn.active {
    background: var(--hub-tint);
    border-color: var(--hub-tint);
    color: var(--primary-color);
    font-weight: 600;
}

.upsells-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

/* ==========================================================================
   CARDS
   Scoped to this page's own class rather than bare .card, which used to
   restyle every card the page happened to contain, modals included.
   ========================================================================== */
.upsells-card {
    background: #fff;
    border: 1px solid var(--hub-border) !important;
    border-radius: 0.625rem !important;
    box-shadow: none !important;
    overflow: hidden;
}

.upsells-card-header {
    background: #fff;
    border-bottom: 1px solid var(--hub-border);
    padding: 0.875rem 1.125rem;
}

.upsells-card-header h6 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--hub-ink);
}

.main-content h5 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--hub-ink);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.upsells-table {
    font-size: 0.8125rem;
    color: #374151;
    margin-bottom: 0;
}

.upsells-table > thead > tr > th {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hub-faint);
    background: #f9fafb;
    border-bottom: 1px solid var(--hub-border);
    padding: 0.625rem 1.125rem;
    white-space: nowrap;
}

.upsells-table > tbody > tr > td {
    padding: 0.75rem 1.125rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--hub-border-soft);
}

.upsells-table > tbody > tr:last-child > td {
    border-bottom: 0;
}

.upsells-table > tbody > tr:hover {
    background-color: var(--hub-row-active);
}

/* The expandable detail row must not read as a hoverable row of its own */
.upsells-table > tbody > tr.collapse:hover,
.upsells-table > tbody > tr.collapsing:hover {
    background-color: transparent;
}

.collapse td {
    border-top: none !important;
}

.cursor-pointer {
    cursor: pointer;
}

/* ==========================================================================
   ROW ACTION BUTTONS — same 32px control as Tasks and Campaigns
   ========================================================================== */
.upsells-actions {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
}

.upsells-icon-btn {
    width: 32px;
    height: 32px;
    flex: none;
    border: 1px solid var(--hub-line);
    border-radius: 0.4375rem;
    background: #fff;
    display: grid;
    place-items: center;
    color: var(--hub-muted);
    font-size: 0.875rem;
}

.upsells-icon-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.upsells-icon-btn.upsells-approve:hover {
    border-color: #15803d;
    color: #15803d;
}

.upsells-icon-btn.upsells-deny:hover {
    border-color: #b42318;
    color: #b42318;
}

.upsells-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border: 1px solid var(--hub-line);
    background: #fff;
    color: var(--hub-muted);
    border-radius: 0.4375rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.upsells-text-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ==========================================================================
   CHARTS & INSIGHTS
   ========================================================================== */
.chart-container {
    position: relative;
    height: 300px;
}

/* ==========================================================================
   STATUS PILLS
   The JS writes "badge bg-upsell-<state>"; these give those the stage-pill look
   without touching the render code.
   ========================================================================== */
.badge[class*="bg-upsell-"] {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.45;
    padding: 0.1875rem 0.625rem;
    border-radius: 99px;
}

.bg-upsell-accepted {
    background-color: #e3f5ea !important;
    color: #15803d !important;
}

.bg-upsell-sent,
.bg-upsell-pending {
    background-color: var(--hub-tint) !important;
    color: var(--primary-color) !important;
}

.bg-upsell-declined {
    background-color: #fdeaea !important;
    color: #b42318 !important;
}

.bg-upsell-expired {
    background-color: var(--hub-fill) !important;
    color: var(--hub-muted) !important;
}

/* ==========================================================================
   COLUMN WIDTH BALANCING & SPACING
   ========================================================================== */
/* Balance column widths for better visual symmetry */
#upsells-table {
    width: 100%; /* Ensure table uses full container width */
    table-layout: fixed; /* Ensure consistent column widths */
}

#upsells-table th:nth-child(1),
#upsells-table td:nth-child(1) {
    width: 18%; /* Time */
}

#upsells-table th:nth-child(2),
#upsells-table td:nth-child(2) {
    width: 24%; /* Guest Name */
}

#upsells-table th:nth-child(3),
#upsells-table td:nth-child(3) {
    width: 24%; /* Upsell Item */
}

#upsells-table th:nth-child(4),
#upsells-table td:nth-child(4) {
    width: 17%; /* Revenue */
    text-align: center; /* Center-align revenue values for better balance */
}

#upsells-table th:nth-child(4) {
    text-align: center; /* Center-align revenue header */
}

#upsells-table th:nth-child(5),
#upsells-table td:nth-child(5) {
    width: 17%; /* Status with chevron */
}

/* Uniform padding for all cells */
#upsells-table th,
#upsells-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

/* Header styling for better visual hierarchy */
#upsells-table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #6c757d;
    border-bottom: 2px solid #dee2e6;
}

/* Style chevron inline with status */
.badge + .bi-chevron-down,
.badge + .bi-chevron-up {
    font-size: 0.75rem;
    vertical-align: middle;
    transition: transform 0.2s ease;
    cursor: pointer;
    margin-left: 0.5rem;
}

/* Rotate chevron when expanded */
.bi-chevron-up {
    transform: rotate(180deg);
}

/* Ensure first column (Time) has consistent formatting */
#upsells-table td:nth-child(1) {
    white-space: nowrap; /* Prevent time wrapping */
    color: #6c757d; /* Slightly muted color */
}

/* Clickable row hover state for better UX */
#upsells-table tbody tr.cursor-pointer:hover {
    background-color: rgba(0, 123, 255, 0.05);
    transition: background-color 0.15s ease-in-out;
}

/* Ensure status badges have consistent width */
#upsells-table .badge {
    min-width: 75px;
    display: inline-block;
}

/* ==========================================================================
   PHOTO MANAGEMENT STYLING
   ========================================================================== */
/* Photo grid container */
#modal-photo-grid,
#addon-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Photo item container */
.photo-item {
    position: relative;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

/* Ensure all photos are consistently sized */
.photo-item img {
    width: 100% !important;
    height: 150px !important;
    object-fit: cover !important;
    display: block;
    max-width: 100% !important;
    border-radius: 6px;
}

/* Primary photo highlight */
.photo-item.primary {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Photo actions overlay */
.photo-item .photo-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 0.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show actions on hover */
.photo-item:hover .photo-actions {
    opacity: 1;
}

/* Photo action buttons */
.photo-item .photo-actions button {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.photo-item .photo-actions button:hover {
    background: white;
}

/* Responsive photo grid */
@media (max-width: 768px) {
    .photo-item img {
        height: 120px !important;
    }
}

/* Upload zone styling */
.upload-zone {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-zone:hover {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.upload-zone.dragover {
    border-color: #0d6efd;
    background: #e7f1ff;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.upsells-primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    border-radius: 0.4375rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.upsells-primary-btn:hover {
    background: #0b5ed7;
    border-color: #0b5ed7;
}

/* Room codes read as data, not as inline code samples */
.upsells-table code {
    color: var(--hub-muted);
    background: var(--hub-fill);
    padding: 0.125rem 0.4375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

/* Inactive-section counts sit inside a clickable card header */
#inactive-rooms-count,
#inactive-addons-count {
    background: var(--hub-fill) !important;
    color: var(--hub-muted) !important;
    font-weight: 600;
}

/* "Which pricing mode is active" note — replaces alert-info, whose blue fought
   both the app blue and the selected pricing card */
.upsells-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: var(--hub-fill);
    border-radius: var(--hub-radius);
    padding: 0.6875rem 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--hub-ink);
}

.upsells-note i {
    color: var(--hub-muted);
    flex: none;
    margin-top: 0.125rem;
}

/* Tier pricing amounts */
#tier-pricing-section .input-group-text {
    background: #f9fafb;
    border-color: var(--hub-line);
    color: var(--hub-muted);
    font-size: 0.8125rem;
}

#tier-pricing-section .form-control {
    border-color: var(--hub-line);
    font-size: 0.8125rem;
}

#tier-pricing-section h6,
#tier-pricing-section .form-label {
    font-size: 0.8125rem;
    color: var(--hub-ink);
}

/* ==========================================================================
   MODALS — same chrome as the page
   ========================================================================== */
.upsells-modal {
    border: 0;
    border-radius: 0.75rem;
    overflow: hidden;
}

.upsells-modal .modal-header {
    background: #fff;
    border-bottom: 1px solid var(--hub-border);
    padding: 1rem 1.25rem;
}

.upsells-modal .modal-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--hub-ink);
}

.upsells-modal .modal-body {
    padding: 1.25rem;
}

.upsells-modal .modal-footer {
    background: var(--hub-canvas);
    border-top: 1px solid var(--hub-border);
    padding: 0.875rem 1.25rem;
    gap: 0.5rem;
}

.upsells-modal .modal-footer > * {
    margin: 0;
}

/* Sub-tabs inside a modal: the same underline bar as the page tabs, tightened */
.upsells-modal-tabs {
    border-bottom: 1px solid var(--hub-border);
    gap: 1.375rem;
    flex-wrap: nowrap;
}

.upsells-modal-tabs .nav-link {
    padding: 0.625rem 0.125rem;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 0;
    color: var(--hub-muted);
    font-size: 0.84375rem;
    font-weight: 500;
    background: transparent;
}

.upsells-modal-tabs .nav-link:hover {
    border-bottom-color: var(--hub-line);
    color: var(--hub-ink);
}

.upsells-modal-tabs .nav-link.active {
    background: transparent;
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

/* Form controls inside the page's modals */
.upsells-modal .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--hub-muted);
    margin-bottom: 0.3125rem;
}

.upsells-modal .form-control,
.upsells-modal .form-select {
    font-size: 0.84375rem;
    border-color: var(--hub-line);
    border-radius: var(--hub-radius);
    padding: 0.5625rem 0.75rem;
}

.upsells-modal .form-select {
    padding-right: 2rem;
}

.upsells-modal .form-control:focus,
.upsells-modal .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--hub-tint);
}

.upsells-modal .form-text {
    font-size: 0.71875rem;
    color: var(--hub-faint);
}

.upsells-modal .input-group-text {
    background: #f9fafb;
    border-color: var(--hub-line);
    color: var(--hub-muted);
    font-size: 0.84375rem;
}

.upsells-modal .form-check-label {
    font-size: 0.84375rem;
}

/* ==========================================================================
   DYNAMIC PRICING EXPLANATION
   ========================================================================== */
.upsells-lead {
    font-size: 0.84375rem;
    color: var(--hub-ink);
    margin: 0 0 0.875rem;
}

.pricing-formula {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #f9fafb;
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
}

.pricing-formula-term {
    background: #fff;
    border: 1px solid var(--hub-line);
    border-radius: 99px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--hub-ink);
}

.pricing-formula-op {
    color: var(--hub-faint);
    font-size: 0.9375rem;
}

.pricing-terms {
    margin: 0 0 0.875rem;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.3125rem 0.875rem;
    align-items: baseline;
}

.pricing-terms dt {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--hub-ink);
    white-space: nowrap;
}

.pricing-terms dd {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--hub-muted);
}

.upsells-caveat {
    margin: 0;
    font-size: 0.75rem;
    color: var(--hub-faint);
    line-height: 1.5;
}

/* A control that belongs to the section below it, not inside its card */
.upsells-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.875rem;
}

/* ==========================================================================
   ADD-ON FORM — grouped sections instead of one long column
   ========================================================================== */
.addon-sections {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.addon-section {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.addon-section-head {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hub-faint);
    padding-bottom: 0.4375rem;
    border-bottom: 1px solid var(--hub-border-soft);
}

.addon-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.875rem 1.25rem;
    align-items: start;
}

@media (max-width: 767.98px) {
    .addon-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* A switch and its explanation on one line, so the eye doesn't hunt */
.addon-switch {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin: 0;
    cursor: pointer;
}

.addon-switch .form-check-input {
    margin: 0.125rem 0 0;
    width: 16px;
    height: 16px;
    flex: none;
}

.addon-switch > span {
    min-width: 0;
}

.addon-switch strong {
    display: block;
    font-size: 0.84375rem;
    font-weight: 600;
    color: var(--hub-ink);
}

.addon-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--hub-faint);
    line-height: 1.45;
    margin-top: 0.125rem;
}

.addon-hint-inline {
    color: var(--hub-faint);
}

.addon-inline-check {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    color: var(--hub-ink-soft);
    cursor: pointer;
}

.addon-inline-check .form-check-input {
    margin: 0;
    width: 15px;
    height: 15px;
    flex: none;
}

.addon-variant-grid {
    padding-left: 1.625rem;
}

.addon-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.addon-chips .hub-toggle-chip {
    margin: 0;
    cursor: pointer;
}

/* Day picker — seven equal squares, replacing the full-width btn-group */
.addon-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
}

.addon-day {
    display: grid;
    place-items: center;
    height: 36px;
    margin: 0;
    border: 1px solid var(--hub-line);
    border-radius: var(--hub-radius);
    background: #fff;
    color: var(--hub-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.addon-day:hover {
    border-color: #cfd6dd;
    color: var(--hub-ink);
}

.addon-day.active {
    background: var(--hub-tint);
    border-color: var(--hub-tint);
    color: var(--primary-color);
}
