/* =============================================
   Customer Portal — Unified Sidebar Layout
   ============================================= */

:root {
    --portal-sidebar-width: 280px;
    --portal-sidebar-bg: var(--color-background, #ffffff);
    --portal-sidebar-border: var(--color-border-light, #e5e7eb);
    --portal-content-bg: var(--color-surface-alt, #f5f6fa);
    --portal-nav-active-bg: var(--portal-theme, #4361ee);
    --portal-nav-active-color: #fff;
    --portal-nav-hover-bg: var(--color-surface-hover, #f0f1f5);
    --portal-card-bg: var(--color-background, #ffffff);
    --portal-card-border: var(--color-border-light, #d5d7de);
    --portal-card-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    --portal-card-radius: 12px;
    --portal-heading-color: var(--color-text, #1a1a2e);
    --portal-text-muted: var(--color-text-muted, #6b7280);
    --portal-stat-blue: #4361ee;
    --portal-stat-green: #2ec4b6;
    --portal-stat-gold: #e9a820;
    --portal-stat-purple: #7c3aed;
}

/* ── Base ──────────────────────────────────── */
.portal-body {
    background-color: var(--portal-content-bg);
    min-height: 100vh;
    margin: 0;
}

/* ── Layout Wrapper ───────────────────────── */
.portal-layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────── */
.portal-sidebar {
    width: var(--portal-sidebar-width);
    min-width: var(--portal-sidebar-width);
    background: var(--portal-sidebar-bg);
    border-right: 1px solid var(--portal-sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.portal-sidebar-header {
    padding: 1.75rem 1.5rem 1rem;
    border-bottom: 1px solid var(--portal-sidebar-border);
    text-align: center;
}

.portal-sidebar-logo {
    max-height: 40px;
    max-width: 140px;
    object-fit: contain;
    margin-bottom: 0.75rem;
    display: inline-block;
}

.portal-sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--portal-heading-color);
    margin: 0;
    line-height: 1.3;
}

.portal-sidebar-subtitle {
    font-size: 0.85rem;
    color: var(--portal-text-muted);
    margin: 0.15rem 0 0;
}

/* ── Sidebar Nav ──────────────────────────── */
.portal-sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.925rem;
    font-weight: 500;
    color: var(--portal-heading-color);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.portal-nav-item i {
    font-size: 1.15rem;
    width: 1.25rem;
    text-align: center;
}

.portal-nav-item:hover {
    background: var(--portal-nav-hover-bg);
    color: var(--portal-heading-color);
    text-decoration: none;
}

.portal-nav-item-active {
    background: var(--portal-nav-active-bg) !important;
    color: var(--portal-nav-active-color) !important;
}

.portal-nav-item-active i {
    color: var(--portal-nav-active-color);
}

.portal-nav-item-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.portal-nav-item-disabled:hover {
    background: transparent;
}

/* ── Sidebar Footer ───────────────────────── */
.portal-sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--portal-sidebar-border);
}

.portal-signout-link,
.portal-signin-link {
    color: var(--portal-text-muted);
}

.portal-signout-link:hover,
.portal-signin-link:hover {
    color: var(--portal-heading-color);
}

/* ── Main Content ─────────────────────────── */
.portal-main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Minimal Mode (Entry/Login pages) ─────── */
.portal-minimal-main {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* ── Mobile Topbar ────────────────────────── */
.portal-mobile-topbar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--portal-sidebar-bg);
    border-bottom: 1px solid var(--portal-sidebar-border);
    position: sticky;
    top: 0;
    z-index: 99;
}

.portal-mobile-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--portal-heading-color);
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

.portal-mobile-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--portal-heading-color);
}

.portal-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.portal-sidebar-overlay.active {
    display: block;
}

/* ── Footer ───────────────────────────────── */
.portal-footer {
    border-top: 1px solid var(--portal-sidebar-border);
    background: var(--portal-sidebar-bg);
}

/* ── Primary Button (uses theme color) ────── */
.portal-btn-primary {
    background-color: var(--portal-theme, #4361ee);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
}

.portal-btn-primary:hover,
.portal-btn-primary:focus {
    background-color: var(--portal-theme, #4361ee);
    color: #fff;
    filter: brightness(1.1);
}

/* ── Page Heading ─────────────────────────── */
.portal-page-heading {
    margin-bottom: 1.75rem;
}

.portal-page-heading h2 {
    font-weight: 700;
    font-size: 1.65rem;
    color: var(--portal-heading-color);
    margin: 0 0 0.25rem;
}

.portal-page-heading p {
    color: var(--portal-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* ── Stat Cards ───────────────────────────── */
.portal-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.portal-stat-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--portal-card-shadow);
}

.portal-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--portal-text-muted);
    margin-bottom: 0.25rem;
}

.portal-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--portal-heading-color);
    line-height: 1.2;
}

.portal-stat-desc {
    font-size: 0.8rem;
    color: var(--portal-text-muted);
    margin-top: 0.15rem;
}

.portal-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}

.portal-stat-icon-blue { background: var(--portal-stat-blue); }
.portal-stat-icon-green { background: var(--portal-stat-green); }
.portal-stat-icon-gold { background: var(--portal-stat-gold); }
.portal-stat-icon-purple { background: var(--portal-stat-purple); }

/* ── Quick Actions ────────────────────────── */
.portal-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--portal-text-muted);
    margin-bottom: 1rem;
}

.portal-quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.portal-quick-action-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    padding: 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--portal-heading-color);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    display: block;
}

.portal-quick-action-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    color: var(--portal-heading-color);
    text-decoration: none;
}

.portal-quick-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    margin: 0 auto 0.75rem;
}

.portal-quick-action-label {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ── Recent Section ───────────────────────── */
.portal-recent-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    box-shadow: var(--portal-card-shadow);
}

.portal-recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--portal-card-border);
}

.portal-recent-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--portal-heading-color);
}

.portal-recent-body {
    padding: 1.5rem;
}

/* ── Portal Card (generic) ────────────────── */
.portal-card {
    background: var(--portal-card-bg);
    border-radius: var(--portal-card-radius);
    box-shadow: var(--portal-card-shadow);
    border: 1px solid var(--portal-card-border);
}

.portal-card .card-body {
    padding: 2rem;
}

/* ── Service Cards (Book a Service) ───────── */
.portal-service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.portal-service-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-left: 4px solid var(--portal-stat-gold);
    border-radius: var(--portal-card-radius);
    padding: 1.25rem 1.5rem;
    transition: box-shadow 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--portal-heading-color);
    display: block;
}

.portal-service-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    color: var(--portal-heading-color);
    text-decoration: none;
}

.portal-service-card h5 {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
}

.portal-service-card p {
    color: var(--portal-text-muted);
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.portal-service-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.88rem;
    color: var(--portal-text-muted);
}

.portal-service-meta i {
    margin-right: 0.25rem;
}

.portal-service-price {
    font-weight: 700;
    color: var(--portal-heading-color);
}

/* ── OTP Input ────────────────────────────── */
.portal-otp-input {
    width: 48px;
    height: 54px;
    font-size: 22px;
    font-weight: bold;
    border: 2px solid var(--portal-card-border);
    border-radius: 8px;
    text-align: center;
}

.portal-otp-input:focus {
    border-color: var(--portal-theme, #4361ee);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.2);
    outline: none;
}

/* ── Business Selection Cards ─────────────── */
.portal-biz-card {
    background: var(--portal-card-bg);
    border: 2px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.portal-biz-card:hover {
    border-color: var(--portal-theme, #4361ee);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.portal-biz-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: var(--portal-nav-hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    color: var(--portal-text-muted);
}

.portal-biz-name {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
    color: var(--portal-heading-color);
}

.portal-biz-location {
    font-size: 0.85rem;
    color: var(--portal-text-muted);
}

/* ── Empty State ──────────────────────────── */
.portal-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--portal-text-muted);
}

.portal-empty-state i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ── Invoice/Document List ────────────────── */
.portal-invoice-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.portal-invoice-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    padding: 1.25rem;
    transition: box-shadow 0.15s ease;
}

.portal-invoice-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.portal-invoice-card-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.portal-invoice-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.portal-invoice-number {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--portal-heading-color);
}

.portal-invoice-date {
    font-size: 0.85rem;
    color: var(--portal-text-muted);
}

.portal-invoice-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.portal-invoice-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--portal-heading-color);
}

.portal-invoice-total-lg {
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--portal-heading-color);
}

.portal-invoice-due {
    font-size: 0.82rem;
    color: var(--portal-text-muted);
    margin-top: 0.35rem;
}

.portal-invoice-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
}

/* ── Invoice Status Badges ────────────────── */
.portal-invoice-status {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.portal-status-paid { background: #d4edda; color: #155724; }
.portal-status-unpaid { background: #fff3cd; color: #856404; }
.portal-status-overdue { background: #f8d7da; color: #721c24; }
.portal-status-partial { background: #d1ecf1; color: #0c5460; }
.portal-status-draft { background: #e2e3e5; color: #383d41; }
.portal-status-sent { background: #fff3cd; color: #856404; }
.portal-status-accepted { background: #d4edda; color: #155724; }
.portal-status-rejected { background: #f8d7da; color: #721c24; }
.portal-status-expired { background: #f8d7da; color: #721c24; }
.portal-status-reviewed { background: #cfe2ff; color: #084298; }
.portal-status-converted { background: #cfe2ff; color: #084298; }

/* ── Accept / Reject Buttons ──────────────── */
.portal-btn-accept {
    background: #198754;
    color: #fff;
    border: none;
    font-weight: 600;
}

.portal-btn-accept:hover { background: #157347; color: #fff; }

.portal-btn-reject {
    background: transparent;
    color: #dc3545;
    border: 2px solid #dc3545;
    font-weight: 600;
}

.portal-btn-reject:hover { background: #dc3545; color: #fff; }

/* ── Pay Button ───────────────────────────── */
.portal-btn-pay {
    background-color: var(--portal-theme, #4361ee) !important;
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-weight: 600;
}

.portal-btn-pay:hover,
.portal-btn-pay:focus {
    background-color: var(--portal-theme, #4361ee) !important;
    color: #fff !important;
    filter: brightness(1.1);
}

/* ── Invoice Detail ───────────────────────── */
.portal-invoice-header-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
}

.portal-invoice-meta-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--portal-text-muted);
    margin-bottom: 0.2rem;
}

.portal-invoice-meta-value {
    font-weight: 600;
    color: var(--portal-heading-color);
}

/* ── Line Items Table ─────────────────────── */
.portal-line-items-table {
    margin: 0;
}

.portal-line-items-table thead th {
    background: var(--portal-nav-hover-bg);
    border-bottom: 2px solid var(--portal-card-border);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--portal-text-muted);
    padding: 0.85rem 1.25rem;
    font-weight: 600;
}

.portal-line-items-table tbody td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--portal-nav-hover-bg);
    vertical-align: top;
    white-space: pre-line;
}

.portal-line-items-total td {
    padding: 1rem 1.25rem;
    border-top: 2px solid var(--portal-card-border);
    background: var(--portal-nav-hover-bg);
}

/* ── Payment Details ──────────────────────── */
.portal-payment-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.portal-ref-number {
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

/* ── Alert Styles ─────────────────────────── */
.portal-alert-info {
    background: #e8f4fd;
    border: 1px solid #b6d9f2;
    color: #0c5a8a;
    border-radius: 8px;
    padding: 1rem;
}

.portal-alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-alert-muted {
    background: var(--portal-nav-hover-bg);
    border: 1px solid var(--portal-card-border);
    color: var(--portal-text-muted);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Messages Page ────────────────────────── */
.portal-message-form-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.portal-message-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
}

.portal-message-card-inbound {
    border-left: 3px solid var(--portal-theme, #4361ee);
}

.portal-message-card-outbound {
    border-left: 3px solid var(--portal-stat-green);
}

/* ── Review Page ──────────────────────────── */
.portal-star-rating {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.portal-star-rating .star {
    font-size: 2rem;
    cursor: pointer;
    color: var(--portal-card-border);
    transition: color 0.1s ease;
}

.portal-star-rating .star.active,
.portal-star-rating .star:hover {
    color: var(--portal-stat-gold);
}

.portal-review-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

/* ── Appointment Card ─────────────────────── */
.portal-appointment-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-card-border);
    border-radius: var(--portal-card-radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.portal-appointment-date {
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.portal-appointment-date .day {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--portal-heading-color);
    line-height: 1;
}

.portal-appointment-date .month {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--portal-text-muted);
}

.portal-appointment-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.2rem;
    color: var(--portal-heading-color);
}

.portal-appointment-info p {
    font-size: 0.85rem;
    color: var(--portal-text-muted);
    margin: 0;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 991.98px) {
    .portal-mobile-topbar {
        display: flex;
    }

    .portal-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.25s ease;
        box-shadow: none;
    }

    .portal-sidebar.portal-sidebar-open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .portal-main-content {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 575.98px) {
    .portal-card .card-body {
        padding: 1.5rem;
    }

    .portal-otp-input {
        width: 40px;
        height: 46px;
        font-size: 18px;
    }

    .portal-stat-grid {
        grid-template-columns: 1fr;
    }

    .portal-quick-action-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .portal-service-grid {
        grid-template-columns: 1fr;
    }

    .portal-invoice-card-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .portal-invoice-right {
        align-items: flex-start;
        flex-direction: row;
        gap: 0.75rem;
    }

    .portal-invoice-header-row {
        gap: 1rem;
    }

    .portal-line-items-table thead th,
    .portal-line-items-table tbody td {
        padding: 0.65rem 0.75rem;
        font-size: 0.88rem;
    }

    .portal-payment-details {
        grid-template-columns: 1fr 1fr;
    }

    .portal-main-content {
        padding: 1rem 0.75rem;
    }
}
