/* ============================================================
   Client Portal — styles.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green:        #10b981;
    --green-dark:   #059669;
    --green-light:  #d1fae5;
    --blue:         #0ea5e9;
    --blue-light:   #e0f2fe;
    --amber:        #f59e0b;
    --amber-light:  #fef3c7;
    --red:          #ef4444;
    --red-light:    #fee2e2;
    --purple:       #8b5cf6;
    --grey:         #6b7280;

    --bg:           #f0fdf4;
    --surface:      #ffffff;
    --border:       #d1fae5;
    --border-grey:  #e5e7eb;
    --text:         #111827;
    --text-muted:   #6b7280;
    --text-light:   #9ca3af;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:    0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
    --radius:       12px;
    --radius-sm:    8px;
    --radius-lg:    16px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

/* ── Auth overlay ───────────────────────────────────────────── */
#auth-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 50%, #d1fae5 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.auth-header {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
    padding: 28px 32px 22px;
    text-align: center;
    color: white;
}

.auth-logo {
    height: 52px;
    object-fit: contain;
    margin-bottom: 10px;
}

.auth-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.auth-header p {
    font-size: 0.85rem;
    opacity: .85;
}

.auth-body {
    padding: 28px 32px 32px;
}

.auth-step { display: none; }
.auth-step.active { display: block; }

/* legacy – keep for any stray references */
.auth-view { display: none; }
.auth-view.active { display: block; }

.auth-message {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}
.auth-message.success { background: var(--green-light); color: #065f46; display: block; }
.auth-message.error   { background: var(--red-light);   color: #991b1b; display: block; }
.auth-message.info    { background: var(--blue-light);  color: #0c4a6e; display: block; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border-grey);
    border-radius: var(--radius-sm);
    font-size: 0.93rem;
    color: var(--text);
    background: white;
    transition: border-color .2s, box-shadow .2s;
    font-family: 'Inter', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    transition: opacity .15s, transform .1s;
    text-decoration: none;
}

.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--green);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1.5px solid var(--border-grey);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-outline-green {
    background: transparent;
    color: var(--green);
    border: 1.5px solid var(--green);
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-link {
    background: none;
    border: none;
    color: var(--green);
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

/* ── Main layout ────────────────────────────────────────────── */
#portal-wrap {
    display: none;
    min-height: 100vh;
    flex-direction: column;
}
#portal-wrap.visible { display: flex; }

.portal-header {
    background: white;
    border-bottom: 1px solid var(--border-grey);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.portal-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.portal-logo img {
    height: 36px;
    object-fit: contain;
}

.portal-logo-text {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--green);
}

.portal-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.83rem;
    color: var(--text-muted);
}

.portal-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Tab navigation ─────────────────────────────────────────── */
.portal-nav {
    background: white;
    border-bottom: 1px solid var(--border-grey);
}

.portal-nav-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
}
.portal-nav-inner::-webkit-scrollbar { display: none; }

.portal-tab {
    padding: 14px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 2.5px solid transparent;
    transition: color .2s, border-color .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-tab:hover { color: var(--green); }

.portal-tab.active {
    color: var(--green);
    border-bottom-color: var(--green);
}

/* ── Content area ───────────────────────────────────────────── */
.portal-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
    flex: 1;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Page titles ────────────────────────────────────────────── */
.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i { color: var(--green); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-grey);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-sm { padding: 14px 16px; }

.card-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* ── KPI grid ───────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border-grey);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

/* ── Status badges ──────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-green    { background: var(--green-light); color: #065f46; }
.badge-blue     { background: var(--blue-light);  color: #0c4a6e; }
.badge-amber    { background: var(--amber-light);  color: #78350f; }
.badge-red      { background: var(--red-light);   color: #991b1b; }
.badge-grey     { background: #f3f4f6;             color: #374151; }
.badge-purple   { background: #ede9fe;             color: #4c1d95; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border-grey);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.portal-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: #f9fafb;
    border-bottom: 1px solid var(--border-grey);
}

.portal-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-grey);
    vertical-align: middle;
}

.portal-table tr:last-child td { border-bottom: none; }
.portal-table tr:hover td { background: #f9fafb; }

/* ── Alert banners ──────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-amber { background: var(--amber-light); color: #78350f; border: 1px solid #fde68a; }
.alert-green { background: var(--green-light); color: #065f46; border: 1px solid #6ee7b7; }
.alert-red   { background: var(--red-light);   color: #991b1b; border: 1px solid #fca5a5; }
.alert-blue  { background: var(--blue-light);  color: #0c4a6e; border: 1px solid #7dd3fc; }

/* ── Job status colors ──────────────────────────────────────── */
.job-scheduled   { color: #0ea5e9; }
.job-completed   { color: #10b981; }
.job-missed      { color: #f59e0b; }
.job-bin_not_out { color: #ef4444; }
.job-cancelled   { color: #9ca3af; }
.job-in_progress { color: #8b5cf6; }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border-grey);
    margin: 16px 0;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    opacity: .3;
    margin-bottom: 10px;
    display: block;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Loading ────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid #d1fae5;
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td {
    text-align: center;
    padding: 28px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Account form ───────────────────────────────────────────── */
.account-section {
    background: var(--surface);
    border: 1px solid var(--border-grey);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.account-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-grey);
    display: flex;
    align-items: center;
    gap: 7px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-grey);
    font-size: 0.88rem;
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-muted); font-size: 0.82rem; }
.info-row-value { font-weight: 600; }

/* ── Email confirm banner ───────────────────────────────────── */
#confirm-banner {
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    padding: 10px 20px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #78350f;
}
#confirm-banner.visible { display: flex; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 28px;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions .btn { flex: 1; justify-content: center; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .auth-body { padding: 20px; }
    .portal-content { padding: 12px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .modal-actions { flex-direction: column; }

    /* ── Activity table → card layout on mobile ── */
    .table-wrap {
        border-left: none;
        border-right: none;
        border-radius: 0;
        overflow-x: visible;
    }

    /* Convert table into a block list of cards */
    .portal-table,
    .portal-table tbody { display: block; width: 100%; }

    /* Hide the header row */
    .portal-table thead { display: none; }

    /* Each row becomes a card */
    .portal-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto auto;
        column-gap: 10px;
        row-gap: 0;
        padding: 12px 14px;
        border-bottom: 1px solid var(--border-grey);
        background: #fff;
    }
    .portal-table tr:last-child { border-bottom: none; }
    .portal-table tr:hover td { background: transparent; }

    /* Reset all cell padding — grid container handles spacing */
    .portal-table td {
        padding: 2px 0;
        border-bottom: none;
    }

    /* Row 1 left  — Date (col 1) */
    .portal-table td:nth-child(1) {
        grid-row: 1; grid-column: 1;
        font-size: 0.82rem;
        color: var(--text-muted);
        padding-top: 0;
        align-self: center;
    }
    /* Row 1 right — Status badge (col 2) */
    .portal-table td:nth-child(2) {
        grid-row: 1; grid-column: 2;
        text-align: right;
        align-self: center;
    }
    /* Hidden: Description (3) */
    .portal-table td:nth-child(3) { display: none; }
    /* Row 2 left  — Invoice # (col 5) */
    .portal-table td:nth-child(5) {
        grid-row: 2; grid-column: 1;
        font-size: 0.85rem;
        padding-top: 4px;
        align-self: center;
    }
    /* Row 2 right — Amount (col 6) */
    .portal-table td:nth-child(6) {
        grid-row: 2; grid-column: 2;
        text-align: right;
        font-size: 1.05rem;
        font-weight: 700;
        color: #111;
        padding-top: 4px;
        align-self: center;
    }
    /* Row 3 full width — Payment details / Paid badge (col 7) */
    .portal-table td:nth-child(7) {
        grid-row: 3; grid-column: 1 / -1;
        padding-top: 4px;
        font-size: 0.8rem;
    }
    /* Row 4 full width — Photos (col 4) */
    .portal-table td:nth-child(4) {
        grid-row: 4; grid-column: 1 / -1;
        padding-top: 8px;
    }
    /* Bigger thumbnails on mobile since there's room */
    .portal-table td:nth-child(4) img {
        height: 60px !important;
        width: 60px !important;
        border-radius: 6px !important;
    }
    /* Row 5 full width — Actions / Pay buttons (col 8) */
    .portal-table td:nth-child(8) {
        grid-row: 5; grid-column: 1 / -1;
        padding-top: 10px;
    }
    /* Make Pay/Cancel buttons full-width and tappable on mobile */
    .portal-table td:nth-child(8) > div {
        flex-direction: row !important;
        gap: 8px !important;
        flex-wrap: wrap;
    }
    .portal-table td:nth-child(8) button {
        flex: 1;
        min-width: 80px;
        padding: 9px 14px !important;
        font-size: 0.88rem !important;
        border-radius: 8px !important;
        justify-content: center;
    }
}
