/* ============================================================
   KeysCom — Customer Account area styles (Phase 10)
   Append to wwwroot/css/storefront.css (or load separately).
   ============================================================ */

/* ---- Header user widget ------------------------------------ */
.header-account {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.92rem;
    margin-left: 1rem;
}
.header-account-link {
    color: inherit;
    text-decoration: none;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
}
.header-account-link:hover { background: rgba(0,0,0,0.04); }
.header-account-icon { margin-right: 0.35rem; }
.header-account-name { font-weight: 500; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.header-account-sep { color: #9ca3af; }

/* ---- Signed-in account dropdown ---------------------------- */
.header-account { position: relative; }
.header-account-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
}
.header-account-toggle:hover { background: rgba(0,0,0,0.04); }
.header-account-caret { font-size: 0.7rem; color: #6b7280; }
.header-account-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 12rem;
    background: #fff;
    border: 1px solid var(--sf-border, #e3e7ec);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    padding: 0.35rem;
    z-index: 200;
}
.header-account-menu a,
.header-account-signout {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    color: var(--sf-text, #1f2937);
    text-decoration: none;
    font-size: 0.9rem;
    background: none;
    border: 0;
    cursor: pointer;
}
.header-account-menu a:hover,
.header-account-signout:hover { background: var(--sf-surface, #f1f5f9); }
.header-account-signout {
    border-top: 1px solid var(--sf-border, #e3e7ec);
    margin-top: 0.25rem;
    color: #b91c1c;
}

/* ---- Auth pages (Login / Register / Forgot / Reset) -------- */
.auth-page {
    max-width: 480px;
    margin: 2.5rem auto;
    padding: 0 1rem;
}
.auth-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.auth-title { margin: 0 0 0.35rem; font-size: 1.6rem; }
.auth-sub { color: #6b7280; margin: 0 0 1.5rem; }
.auth-sub a { color: var(--c-accent, #2563eb); }
.auth-foot { margin-top: 1.25rem; text-align: center; color: #6b7280; }
.auth-foot a { color: var(--c-accent, #2563eb); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

.auth-form .form-row { margin-bottom: 1rem; }
.auth-form .form-row label {
    display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem;
}
.auth-form .form-row input[type="text"],
.auth-form .form-row input[type="email"],
.auth-form .form-row input[type="tel"],
.auth-form .form-row input[type="password"] {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.95rem; box-sizing: border-box;
}
.auth-form .form-row input:focus {
    outline: none; border-color: var(--c-accent, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.auth-form .form-row.two-col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
.form-hint { display: block; color: #6b7280; font-size: 0.82rem; margin-top: 0.25rem; }
.field-error { display: block; color: #b91c1c; font-size: 0.85rem; margin-top: 0.25rem; }
.checkbox-row {
    display: flex; align-items: center; justify-content: space-between;
}
.checkbox-label { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.forgot-link { color: var(--c-accent, #2563eb); font-size: 0.88rem; text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }

/* ---- Buttons (account / auth pages) ------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.15rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}
.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary,
a.btn-primary {
    background: var(--sf-accent, #2563eb);
    border-color: var(--sf-accent, #2563eb);
    color: #fff;
}
.btn-primary:hover,
a.btn-primary:hover {
    background: var(--sf-accent-hover, #1d4ed8);
    border-color: var(--sf-accent-hover, #1d4ed8);
    color: #fff;
    text-decoration: none;
}
.btn-primary:active { transform: translateY(1px); }

.btn-secondary,
a.btn-secondary {
    background: #fff;
    border-color: var(--sf-border, #d1d5db);
    color: var(--sf-text, #1f2937);
}
.btn-secondary:hover,
a.btn-secondary:hover {
    background: var(--sf-surface, #f8fafc);
    border-color: #9ca3af;
    text-decoration: none;
}

.btn-block { display: flex; width: 100%; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center; }
.form-actions .btn-block { flex: 1; }

.btn-link {
    color: var(--sf-accent, #2563eb);
    font-size: 0.92rem;
    text-decoration: none;
    padding: 0.6rem 0.4rem;
}
.btn-link:hover { text-decoration: underline; }

/* ---- Logged-in account shell ------------------------------- */
.account-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 2rem;
    /* No own width cap or auto-centering: fill the layout container so the account
       area tracks the theme's Content width — including Full width — exactly like the
       header and the rest of the site. The parent .container supplies the max-width
       and horizontal padding, so a hard 1100px cap here made the account area a narrow
       centred column that ignored the Full-width layout setting. */
    margin: 2rem 0;
}
.account-side {
    border-right: 1px solid #e5e7eb;
    padding-right: 1.5rem;
}
.account-side-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin: 0 0 0.75rem;
}
.account-nav {
    display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1.25rem;
}
.account-nav a {
    color: #374151;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.92rem;
}
.account-nav a:hover { background: #f3f4f6; }
.account-nav a.active { background: var(--c-accent, #2563eb); color: #fff; }
.account-logout-form { margin-top: 0.5rem; }
.account-logout-btn {
    background: none; border: none; padding: 0.5rem 0.75rem;
    color: #6b7280; font-size: 0.9rem; cursor: pointer;
}
.account-logout-btn:hover { color: #b91c1c; }

.account-main h2 { margin-top: 0; }
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { margin: 0 0 0.35rem; }
.page-sub { color: #6b7280; margin: 0; }
.back-link {
    display: inline-block; color: #6b7280; text-decoration: none;
    font-size: 0.88rem; margin-bottom: 0.5rem;
}
.back-link:hover { color: var(--c-accent, #2563eb); }

/* KPI cards */
.kpi-row { display: flex; gap: 1rem; margin: 1rem 0 1.5rem; }
.kpi-card {
    flex: 1; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 8px; padding: 1rem 1.25rem;
}
.kpi-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; }
.kpi-value { font-size: 1.6rem; font-weight: 600; color: #111827; margin-top: 0.2rem; }

.section-heading { margin: 2rem 0 0.75rem; font-size: 1.1rem; }

/* Data table refinements for account area */
.account-main .data-table {
    width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;
}
.account-main .data-table th, .account-main .data-table td {
    padding: 0.75rem 1rem; text-align: left;
}
.account-main .data-table thead { background: #f9fafb; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; }
.account-main .data-table tbody tr { border-top: 1px solid #f3f4f6; }
.account-main .data-table .actions { text-align: right; }

.btn-sm {
    display: inline-block; padding: 0.35rem 0.7rem;
    border: 1px solid #d1d5db; border-radius: 5px;
    background: #fff; color: #374151;
    font-size: 0.85rem; text-decoration: none;
}
.btn-sm:hover { background: #f9fafb; border-color: #9ca3af; }

/* Order detail */
.order-status-row {
    display: flex; flex-wrap: wrap; gap: 2rem; padding: 1rem 1.25rem;
    background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px;
    margin-bottom: 1rem;
}
.order-line-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 1rem 1.25rem; margin-bottom: 0.75rem;
}
.order-line-header { display: flex; justify-content: space-between; gap: 1rem; }
.order-line-totals { text-align: right; min-width: 8rem; }
.order-line-total { font-weight: 600; font-size: 1.05rem; }
.order-line-keys { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed #e5e7eb; display: flex; flex-direction: column; gap: 0.6rem; }
.key-row {
    background: #f9fafb; padding: 0.6rem 0.85rem; border-radius: 6px;
}
.key-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; margin-bottom: 0.2rem; }
.key-value code {
    font-family: ui-monospace, monospace; font-size: 0.95rem;
    background: #fff; padding: 0.35rem 0.5rem; border: 1px solid #d1d5db; border-radius: 4px;
    display: inline-block; user-select: all;
}
.order-keys-pending { padding: 0.6rem; }

.order-totals { margin: 1.5rem 0; display: flex; justify-content: flex-end; }
.order-totals table { border-collapse: collapse; min-width: 280px; }
.order-totals th, .order-totals td { padding: 0.4rem 0.85rem; }
.order-totals th { text-align: left; color: #6b7280; font-weight: 500; }
.order-totals td { text-align: right; font-variant-numeric: tabular-nums; }
.order-totals tr.grand th, .order-totals tr.grand td {
    border-top: 1px solid #e5e7eb; padding-top: 0.7rem; font-weight: 700; font-size: 1.05rem; color: #111827;
}

/* Pills */
.pill {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 9999px;
    font-size: 0.78rem; font-weight: 500;
    background: #f3f4f6; color: #374151;
}
.pill-pending { background: #fef3c7; color: #92400e; }
.pill-processing { background: #dbeafe; color: #1e40af; }
.pill-completed, .pill-paid { background: #d1fae5; color: #065f46; }
.pill-cancelled, .pill-refunded, .pill-failed { background: #fee2e2; color: #991b1b; }
.pill-awaitingpayment { background: #fef3c7; color: #92400e; }

/* Form card */
.form-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 1.5rem; max-width: 560px;
}

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.muted { color: #6b7280; }
.muted.small { font-size: 0.82rem; }
.empty-state {
    text-align: center; padding: 2.5rem 1rem;
    background: #f9fafb; border: 1px dashed #d1d5db; border-radius: 8px;
}

/* Responsive */
@media (max-width: 720px) {
    .account-shell { grid-template-columns: 1fr; }
    .account-side { border-right: none; border-bottom: 1px solid #e5e7eb; padding-right: 0; padding-bottom: 1rem; }
    .account-nav { flex-direction: row; flex-wrap: wrap; }
    .order-line-header { flex-direction: column; }
    .order-line-totals { text-align: left; }
}

/* Hide the validation-summary box when there are no errors. ASP.NET Core adds
   the .validation-summary-valid class on a clean page load; without this the
   styled (alert/flash) container would render as an empty coloured box. */
.validation-summary-valid {
    display: none;
}

/* ---- Profile / address cards ------------------------------- */
.address-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
.address-card {
    border: 1px solid var(--sf-border, #e3e7ec);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    background: #fff;
}
.address-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.address-type {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}
.address-lines { margin: 0; line-height: 1.55; font-size: 0.92rem; }

/* ============================================================
   MOBILE (≤600px) — account area + header icon
   Formats the My Account menu as a stacked, dividered list and
   the account list views as label/value cards (see screenshot).
   Desktop layout is untouched.
   ============================================================ */

/* ---- Header: show a single account icon, hide text links ---- */
/* The mobile icon is hidden on desktop; the full widget shows instead. */
.nav-account-mobile { display: none; }

/* Mobile header: matches the two-row header rework in storefront.css (<=720px).
   Show an icon-only account link and present it as a pill identical to the cart,
   so the two sit as a matched pair on the right of row 1. */
@media (max-width: 720px) {
    /* Hide the desktop account widget (dropdown / Sign in · Register text). */
    .header-account-desktop { display: none !important; }

    /* Icon-only account link, styled as a pill to match .nav-cart exactly. */
    .nav-account-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--sf-text);
        padding: 0.4rem 0.7rem;
        background: var(--sf-surface);
        border: 1px solid var(--sf-border);
        border-radius: 999px;
    }
    /* Equal glyph size for account + cart so the pills match. */
    .nav-account-icon,
    .nav-cart .cart-icon { font-size: 1.25rem; line-height: 1; }
    /* Keep the cart pill compact on mobile (icon-only look). */
    .nav-cart { padding: 0.4rem 0.7rem; gap: 0.2rem; }
    .site-nav { gap: 0.5rem; }
}

@media (max-width: 600px) {
    /* ---- My Account menu: stacked, dividered list ---- */
    .account-shell {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        margin: 0;
        padding: 0;
    }
    .account-side {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        padding: 0 0 0.5rem;
    }
    .account-side-title {
        padding: 1rem 1.1rem 0.5rem;
        margin: 0;
    }
    /* Override the 720px row-wrap: go back to a clean vertical list. */
    .account-nav {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0;
        margin: 0;
    }
    .account-nav a {
        padding: 0.85rem 1.1rem;
        border-radius: 0;
        font-size: 1rem;
        color: #374151;
        border-left: 3px solid transparent;
    }
    /* Light divider between items (not after the last). */
    .account-nav a + a { border-top: 1px solid #f1f3f5; }
    .account-nav a:hover { background: #f9fafb; }
    /* Active item: bold text + left accent bar (matches the screenshot). */
    .account-nav a.active {
        background: #f9fafb;
        color: #111827;
        font-weight: 700;
        border-left-color: var(--sf-accent, #2563eb);
    }
    .account-logout-form { padding: 0.25rem 1.1rem 0; }

    .account-main { padding: 0 1.1rem 1.5rem; }
    .page-header { margin-bottom: 1rem; }

    /* ---- List views: turn data-tables into label/value cards ---- */
    .account-main .data-table,
    .account-main .data-table tbody,
    .account-main .data-table tr,
    .account-main .data-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    /* Hide the header row — each cell carries its own label instead. */
    .account-main .data-table thead { display: none; }
    .account-main .data-table {
        border: none;
        background: transparent;
        border-radius: 0;
    }
    .account-main .data-table tr {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.35rem 0;
        margin-bottom: 1rem;
    }
    .account-main .data-table td {
        border: none;
        padding: 0.5rem 1rem;
        text-align: left;
    }
    /* Show the column name (from data-label) as a bold caption per cell. */
    .account-main .data-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        font-size: 0.82rem;
        color: #374151;
        margin-bottom: 0.15rem;
    }
    /* The actions cell (Download / View button) stretches full width. */
    .account-main .data-table td.actions { text-align: left; }
    .account-main .data-table td.actions .btn,
    .account-main .data-table td.actions .btn-sm { width: 100%; }
    /* Soft divider between stacked cells within a card. */
    .account-main .data-table td + td { border-top: 1px solid #f6f7f9; }
}
