/* ═══════════════════════════════════════════
   Ordernaut App Styles
   Design tokens from landing page
   ═══════════════════════════════════════════ */

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

:root {
    --ink: #0a0f1a;
    --ink-light: #0e1425;
    --slate: #1a2233;
    --slate-light: #222d42;
    --muted: #5a6a80;
    --light: #c4cdd8;
    --cream: #f5f2ed;
    --amber: #e8a634;
    --amber-dim: rgba(232, 166, 52, 0.12);
    --amber-hover: #f0b340;
    --teal: #2dd4a8;
    --teal-dim: rgba(45, 212, 168, 0.08);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.1);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.1);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.1);
    --purple: #a882ff;

    --sidebar-width: 240px;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--ink);
    color: var(--cream);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.2;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--ink-light);
    border-right: 1px solid rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}

.sidebar-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    color: var(--cream);
    text-decoration: none;
    padding: 0 0.75rem;
    margin-bottom: 2rem;
}

.sidebar-logo span { color: var(--amber); }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--light);
}

.nav-item.active {
    background: var(--amber-dim);
    color: var(--amber);
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.nav-item-muted { font-size: 0.82rem; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.04);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

/* ═══ MAIN CONTENT ═══ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

/* ═══ PAGES ═══ */
.page { display: none; }
.page.active { display: block; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ═══ STATS GRID ═══ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.stat-card:hover { border-color: rgba(255,255,255,0.1); }

.stat-card-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.stat-card-desc {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.stat-card.accent-teal .stat-card-value { color: var(--teal); }
.stat-card.accent-amber .stat-card-value { color: var(--amber); }

/* ═══ SECTIONS ═══ */
.section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.link {
    color: var(--amber);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.link:hover { text-decoration: underline; }

/* ═══ EMPTY STATE ═══ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255,255,255,0.015);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: var(--radius);
}

.empty-icon {
    color: var(--muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--muted);
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

.empty-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* ═══ BUTTONS ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.15rem;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--amber);
    color: var(--ink);
}

.btn-primary:hover { background: var(--amber-hover); }

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--cream);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-amber {
    background: var(--amber);
    color: var(--ink);
    font-weight: 600;
}

.btn-amber:hover { background: var(--amber-hover); }

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-success {
    background: var(--green-dim);
    color: var(--green);
}

.btn-success:hover { background: rgba(34, 197, 94, 0.2); }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.5rem;
    font-family: 'DM Sans', sans-serif;
}

.btn-back:hover { color: var(--cream); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ═══ SUPPLY TABLE ═══ */
.supply-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius);
    overflow: hidden;
}

.supply-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 600;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.supply-table td {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}

.supply-table tr:last-child td { border-bottom: none; }

.supply-table tr:hover td { background: rgba(255,255,255,0.02); }

.category-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255,255,255,0.06);
    color: var(--light);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
}

.delete-btn:hover {
    color: var(--red);
    background: var(--red-dim);
}

/* ═══ GENERATE BAR ═══ */
.generate-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: var(--slate);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 1rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 40;
    backdrop-filter: blur(16px);
}

.generate-info {
    font-size: 0.9rem;
    color: var(--light);
}

.generate-info span {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    color: var(--amber);
    font-size: 1.1rem;
}

/* ═══ ORDER CARDS ═══ */
.order-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1.5rem;
    align-items: center;
}

.order-card:hover {
    border-color: rgba(232, 166, 52, 0.2);
    background: rgba(255,255,255,0.03);
}

.order-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.3px;
}

.order-card-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.order-card-amount {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
}

.order-card-savings {
    color: var(--teal);
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-draft { background: rgba(255,255,255,0.06); color: var(--muted); }
.status-approved { background: var(--blue-dim); color: var(--blue); }
.status-ordered { background: var(--amber-dim); color: var(--amber); }
.status-delivered { background: var(--green-dim); color: var(--green); }
.status-cancelled { background: var(--red-dim); color: var(--red); }

/* ═══ ORDER DETAIL ═══ */
.order-summary {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.order-summary-text {
    color: var(--light);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.order-meta {
    display: flex;
    gap: 2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.order-meta-item {
    display: flex;
    flex-direction: column;
}

.order-meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 600;
}

.order-meta-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 0.15rem;
}

.order-meta-value.teal { color: var(--teal); }
.order-meta-value.amber { color: var(--amber); }

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

.vendor-group-header {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cream);
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border: 1px solid rgba(255,255,255,0.06);
    border-bottom: none;
}

.vendor-group-items {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.line-item {
    display: grid;
    grid-template-columns: 1fr 80px 100px 100px 100px;
    gap: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    align-items: center;
}

.line-item:last-child { border-bottom: none; }

.line-item-name { color: var(--cream); }
.line-item-savings { color: var(--teal); font-weight: 500; }

.tips-section {
    background: var(--teal-dim);
    border: 1px solid rgba(45, 212, 168, 0.15);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.tips-section h3 {
    color: var(--teal);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.tips-section ul {
    list-style: none;
    padding: 0;
}

.tips-section li {
    padding: 0.35rem 0;
    padding-left: 1.25rem;
    color: var(--light);
    font-size: 0.88rem;
    position: relative;
}

.tips-section li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
}

/* ═══ MODALS ═══ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--slate);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-wide { max-width: 620px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover { color: var(--cream); }

.modal-form {
    padding: 1.5rem;
}

.modal-desc {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 1.25rem;
}

/* ═══ FORMS ═══ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--light);
    margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--cream);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--amber);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6a80' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-group select option {
    background: var(--slate);
    color: var(--cream);
}

.form-group textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

/* ═══ LOADING ═══ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 15, 26, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    flex-direction: column;
}

.loading-overlay.show { display: flex; }

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-spinner p {
    color: var(--light);
    font-size: 1rem;
}

/* ═══ TOAST ═══ */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--slate);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    font-size: 0.88rem;
    color: var(--cream);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: slideIn 0.25s ease;
    max-width: 360px;
}

.toast.error { border-left: 3px solid var(--red); }
.toast.success { border-left: 3px solid var(--teal); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: static;
        flex-direction: row;
        align-items: center;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.04);
    }

    .sidebar-logo { margin-bottom: 0; font-size: 1rem; }
    .sidebar-nav { flex-direction: row; gap: 0; }
    .sidebar-footer { display: none; }
    .nav-item { padding: 0.5rem; font-size: 0; gap: 0; }
    .nav-item svg { margin: 0; }

    body { flex-direction: column; }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }

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

    .page-header {
        flex-direction: column;
        gap: 1rem;
    }

    .order-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .line-item {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .generate-bar { left: 0; }

    .modal { margin: 1rem; }
}
