/* Admin Panel Styles for Wooden Spoon Bakery */

@import url('./admin-app-shell.css');

/* Admin Container */
.admin-container {
    min-height: 100vh;
    background-color: #f8f9fa;
    font-family: 'Open Sans', sans-serif;
}

/* Admin Header */
.admin-header {
    background: linear-gradient(135deg, #9c1c34 0%, #bfa14a 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.admin-header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
}

.admin-nav ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.admin-nav a:hover,
.admin-nav a.active {
    background-color: rgba(255,255,255,0.2);
}

/* Admin Main Content */
.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    margin: 0 0 1rem 0;
    color: #6c757d;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #9c1c34;
    margin: 0;
}

/* Quick Actions */
.quick-actions {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.quick-actions h2 {
    margin: 0 0 1rem 0;
    color: #2d2d2d;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: #9c1c34;
    color: white;
}

.btn-primary:hover {
    background-color: #7a1628;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #bfa14a;
    color: white;
}

.btn-secondary:hover {
    background-color: #a8903f;
    transform: translateY(-2px);
}

.btn-outline {
    background-color: transparent;
    color: #6c757d;
    border: 2px solid #6c757d;
}

.btn-outline:hover {
    background-color: #6c757d;
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* General settings — cross-links when sidebar account strip is condensed */
.settings-related-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.25rem;
    margin-bottom: 1.25rem;
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
}

.settings-related-nav__label {
    font-weight: 700;
    color: #64748b;
    margin-right: 0.35rem;
}

.settings-related-nav__link {
    color: var(--accent-color, #9c1c34);
    font-weight: 600;
    text-decoration: none;
}

.settings-related-nav__link:hover {
    text-decoration: underline;
}

.settings-related-nav__sep {
    color: #cbd5e1;
    user-select: none;
}

/* Sections */
.system-status,
.orders-section,
.settings-section,
.filter-controls {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.recent-activity h2,
.system-status h2,
.orders-section h2,
.settings-section h2,
.filter-controls h2 {
    margin: 0 0 1rem 0;
    color: #2d2d2d;
    border-bottom: 2px solid #f8f9fa;
    padding-bottom: 0.5rem;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.status-label {
    font-weight: 500;
    color: #6c757d;
}

.status-value {
    font-weight: 600;
}

.status-ok {
    color: #28a745;
}

.status-error {
    color: #dc3545;
}

.status-warning {
    color: #ffc107;
}

/* Orders Table */
.orders-table-container {
    overflow-x: auto;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.orders-table th,
.orders-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.orders-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.orders-table tr:hover {
    background-color: #f8f9fa;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-confirmed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
}

.status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

/* Forms */
.settings-form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2d2d2d;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #9c1c34;
}

/* Checkboxes/radios must not inherit the full-width text-input treatment —
   they'd float on their own line instead of sitting inline with their label.
   body.admin-body wins (0-2-1) over the page-local `.xx-field input` rules
   (0-1-1) that keep re-creating this bug (audited: invoice-edit, loans,
   pos-menu, pos-card-tips, positions, vendors all had stretched checkboxes). */
body.admin-body input[type="checkbox"],
body.admin-body input[type="radio"],
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    padding: 0;
    vertical-align: middle;
    accent-color: #9c1c34;
    /* Flex-column field wrappers (align-items:stretch) stretch width:auto children
       to the container — pin the box to its content size there too. */
    align-self: flex-start;
    flex: 0 0 auto;
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
}

.checkbox-group small {
    color: #6c757d;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #fdecee;
    color: #5f1320;
    border: 1px solid #d99aa5;
}

.alert-warning {
    background-color: #fff6db;
    color: #5b4300;
    border: 1px solid #cfb36a;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin: 0 0 1rem 0;
    color: #2d2d2d;
}

/* Filter Controls */
.filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* No Orders */
.no-orders {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

/* Admin Footer */
.admin-footer {
    background: #2d2d2d;
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
}

.admin-footer p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .admin-header {
        padding: 1rem;
    }
    
    .admin-nav ul {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .admin-main {
        padding: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    /* App-style buttons on phones: keep natural width so toolbars/filter rows stay
       compact (the old blanket `width:100%` stacked every button into full-width
       bars). Buttons in a stacked primary-action list still go full width. */
    .action-buttons .btn,
    .form-actions .btn {
        width: 100%;
    }
    
    .status-grid {
        grid-template-columns: 1fr;
    }
    
    .orders-table-container {
        font-size: 0.8rem;
    }

    /* System-wide: any data table in the admin shell scrolls horizontally on small
       screens instead of overflowing the page. Making the <table> a scrollable block
       keeps it inside its container with a single scrollbar (works even for tables
       already inside an overflow wrapper). */
    .admin-main table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-main table thead th {
        white-space: nowrap;
    }

    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .admin-header h1 {
        font-size: 1.5rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   App design system (2026 refresh) — token-driven surfaces, refined shared
   components, and a reusable .ws-* kit. Loaded last (after admin-app/dark css)
   so it lifts the legacy content classes consistently. Colours flow through
   variables; dark mode (html[data-ws-theme="dark"]) overrides the tokens and,
   by higher specificity, any element admin-dark.css already skins.
   ══════════════════════════════════════════════════════════════════════════ */
:root {
    --ws-brand: #9c1c34;
    --ws-brand-strong: #7a1628;
    --ws-brand-soft: #fbe9ec;
    --ws-gold: #bfa14a;
    --ws-surface: #ffffff;
    --ws-surface-2: #f9fafb;
    --ws-bg: #f4f5f7;
    --ws-border: #e7e9ee;
    --ws-border-strong: #d6dae1;
    --ws-text: #1f2937;
    --ws-text-muted: #6b7280;
    --ws-text-faint: #9ca3af;
    --ws-ok: #166534; --ws-ok-bg: #ecfdf5; --ws-ok-bd: #a7f3d0;
    --ws-warn: #92400e; --ws-warn-bg: #fffbeb; --ws-warn-bd: #fde68a;
    --ws-err: #991b1b; --ws-err-bg: #fef2f2; --ws-err-bd: #fecaca;
    --ws-r-sm: 9px;
    --ws-r: 14px;
    --ws-r-lg: 18px;
    --ws-shadow: 0 1px 2px rgba(17,24,39,.04), 0 1px 3px rgba(17,24,39,.06);
    --ws-shadow-md: 0 2px 4px rgba(17,24,39,.05), 0 4px 12px rgba(17,24,39,.07);
    --ws-ring: 0 0 0 3px rgba(156,28,52,.16);
}
html[data-ws-theme="dark"] {
    --ws-brand-soft: #3a1620;
    --ws-surface: #161a20;
    --ws-surface-2: #1b2026;
    --ws-bg: #0f1216;
    --ws-border: #2b323d;
    --ws-border-strong: #39414d;
    --ws-text: #e5e7eb;
    --ws-text-muted: #9ca3af;
    --ws-text-faint: #6b7280;
    --ws-ok-bg: #06281c; --ws-ok-bd: #14532d;
    --ws-warn-bg: #2a210a; --ws-warn-bd: #5a4413;
    --ws-err-bg: #2a1316; --ws-err-bd: #5a1f25;
    --ws-shadow: 0 1px 2px rgba(0,0,0,.4);
    --ws-shadow-md: 0 4px 14px rgba(0,0,0,.45);
    --ws-ring: 0 0 0 3px rgba(220,80,104,.28);
}

/* ——— Refined buttons (theme-neutral: shape, weight, motion) ——— */
.btn {
    border-radius: var(--ws-r-sm);
    font-weight: 600;
    letter-spacing: .01em;
    transition: background-color .18s ease, box-shadow .18s ease, transform .12s ease, border-color .18s ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--ws-ring); }
.btn-primary { background-color: var(--ws-brand); box-shadow: 0 1px 2px rgba(124,22,40,.25); }
.btn-primary:hover { background-color: var(--ws-brand-strong); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,22,40,.28); }
.btn-secondary:hover { transform: translateY(-1px); }
.btn-small { border-radius: 8px; }

/* ——— Refined cards / sections (token surfaces so dark mode follows) ——— */
.stat-card,
.quick-actions,
.system-status,
.orders-section,
.settings-section,
.filter-controls {
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-r);
    box-shadow: var(--ws-shadow);
}
.stat-card { transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--ws-shadow-md); }
.stat-number { color: var(--ws-brand); }
.recent-activity h2,
.system-status h2,
.orders-section h2,
.settings-section h2,
.filter-controls h2 { border-bottom-color: var(--ws-border); }

/* ——— Refined tables ——— */
.orders-table th { background: var(--ws-surface-2); color: var(--ws-text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--ws-border); }
.orders-table td { border-bottom: 1px solid var(--ws-border); }
.orders-table tr:hover { background: var(--ws-surface-2); }

/* ——— Refined form fields (rounded, soft focus ring) ——— */
.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid var(--ws-border-strong);
    border-radius: var(--ws-r-sm);
    background: var(--ws-surface);
    color: var(--ws-text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--ws-brand); box-shadow: var(--ws-ring); }

/* ——— Refined alerts ——— */
.alert { border-radius: var(--ws-r-sm); border: 1px solid transparent; }
.alert-success { background: var(--ws-ok-bg); color: var(--ws-ok); border-color: var(--ws-ok-bd); }
.alert-error { background: var(--ws-err-bg); color: var(--ws-err); border-color: var(--ws-err-bd); }
.alert-warning { background: var(--ws-warn-bg); color: var(--ws-warn); border-color: var(--ws-warn-bd); }

/* ══════════════════════════════════════════════════════════════════════════
   .ws-* component kit — one vocabulary for new & refreshed pages.
   ══════════════════════════════════════════════════════════════════════════ */
.ws-card {
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-r);
    box-shadow: var(--ws-shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.ws-card > h2, .ws-card > h3 { margin: 0 0 12px; font-size: 1rem; color: var(--ws-text); }

.ws-grid { display: grid; gap: 14px; }
.ws-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ws-kpi { background: var(--ws-surface-2); border: 1px solid var(--ws-border); border-radius: 12px; padding: 14px 16px; }
.ws-kpi__l { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ws-text-muted); }
.ws-kpi__v { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--ws-text); }
.ws-kpi__v--brand { color: var(--ws-brand); }

.ws-section-title { font-size: 1rem; font-weight: 700; color: var(--ws-text); margin: 0 0 12px; }

.ws-toolbar { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }

.ws-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.ws-pill--ok { background: var(--ws-ok-bg); color: var(--ws-ok); }
.ws-pill--warn { background: var(--ws-warn-bg); color: var(--ws-warn); }
.ws-pill--err { background: var(--ws-err-bg); color: var(--ws-err); }
.ws-pill--brand { background: var(--ws-brand-soft); color: var(--ws-brand); }
.ws-pill--muted { background: var(--ws-surface-2); color: var(--ws-text-muted); }

.ws-table { width: 100%; border-collapse: collapse; font-size: .9rem; color: var(--ws-text); }
.ws-table th { text-align: left; color: var(--ws-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 7px 8px; border-bottom: 1px solid var(--ws-border); }
.ws-table td { padding: 9px 8px; border-top: 1px solid var(--ws-border); }
.ws-table tbody tr:hover { background: var(--ws-surface-2); }

.ws-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ws-border-strong); background: var(--ws-surface); color: var(--ws-text); border-radius: var(--ws-r-sm); padding: 8px 14px; font: inherit; font-weight: 600; font-size: .86rem; cursor: pointer; transition: background-color .15s ease, box-shadow .15s ease, transform .12s ease; text-decoration: none; }
.ws-btn:hover { background: var(--ws-surface-2); }
.ws-btn:focus-visible { outline: none; box-shadow: var(--ws-ring); }
.ws-btn--primary { background: var(--ws-brand); border-color: var(--ws-brand); color: #fff; }
.ws-btn--primary:hover { background: var(--ws-brand-strong); transform: translateY(-1px); }
.ws-btn[disabled] { opacity: .5; cursor: not-allowed; }
.ws-btn--primary[disabled]:hover { transform: none; background: var(--ws-brand); }

/* Legacy admin header: POST logout button matches nav links */
.admin-nav .ws-admin-logout-form {
    display: inline-block;
    margin: 0;
    padding: 0;
    vertical-align: middle;
}
.admin-header .admin-nav .admin-nav-logout-btn {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    background: transparent;
    border: none;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.admin-header .admin-nav .admin-nav-logout-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

/* Invoice status badges (ws_invoice_status_badge) — theme-aware; was inline light pastels. */
.ws-inv-badge { display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; font-weight:700; }
.ws-inv-badge--draft { color:#6b7280; background:#f3f4f6; }
.ws-inv-badge--sent  { color:#1e40af; background:#dbeafe; }
.ws-inv-badge--paid  { color:#166534; background:#dcfce7; }
.ws-inv-badge--void  { color:#991b1b; background:#fee2e2; }
html[data-ws-theme="dark"] .ws-inv-badge--draft { color:#cbd5e1; background:#232a33; }
html[data-ws-theme="dark"] .ws-inv-badge--sent  { color:#93c5fd; background:rgba(59,130,246,.18); }
html[data-ws-theme="dark"] .ws-inv-badge--paid  { color:#86efac; background:rgba(34,197,94,.15); }
html[data-ws-theme="dark"] .ws-inv-badge--void  { color:#fca5a5; background:rgba(239,68,68,.16); }
