/* Professional styles for CRM Resto */
:root {
    --theme-bg: linear-gradient(180deg, #eef3fb 0%, #f7f9fc 100%);
}

/* Dark theme overrides when body[data-theme="dark"] */
body[data-theme="dark"] {
    --bg: linear-gradient(180deg, #061125 0%, #071126 100%);
    --surface: #071126;
    --surface-strong: #061022;
    --surface-variant: #0d1429;
    --border: rgba(255,255,255,0.08);
    --text: #e6eef8;
    --text-muted: #9aa7be;
    --brand: #58a6ff;
    --brand-dark: #1e6fe8;
    --shadow: 0 18px 40px rgba(0,0,0,0.6);
}
:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-strong: #edf1f7;
    --surface-variant: #f4f6fb;
    --border: #d7dde7;
    --text: #1e293b;
    --text-muted: #55627c;
    --brand: #2d7cff;
    --brand-dark: #1c5fcc;
    --success: #1a7b34;
    --success-soft: #daf6df;
    --warning: #b36c00;
    --warning-soft: #fff4d6;
    --danger: #c92a2a;
    --danger-soft: #f9d6d6;
    --radius: 14px;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--brand);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select, textarea {
    font: inherit;
}

button,
.button {
    background: var(--brand);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 12px 18px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--brand-dark);
}

.button.small {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.button.danger {
    background: var(--danger);
}

.button.danger:hover {
    background: #a82727;
}

.button.secondary {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--border);
}

.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 100px);
    padding: 32px 16px;
}
.auth-card {
    width: 100%;
    max-width: 460px;
    padding: 32px;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
    background: var(--surface);
    border: 1px solid var(--border);
}

.page-content-shell {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px 32px;
}

.auth-container {
    width: min(520px, 100%);
}

.page-shell {
    display: grid;
    grid-template-columns: minmax(250px, 280px) 1fr;
    gap: 24px;
    min-height: 100vh;
    align-items: start;
}

.sidebar {
    margin: 16px 0;
}

.page-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.container {
    width: min(1800px, calc(100% - 32px));
    margin: 0 auto;
    padding: 16px 0 32px;
}

@media (min-width: 1400px) {
    .page-shell {
        grid-template-columns: minmax(260px, 300px) 1fr;
        gap: 24px;
    }
}

.public-page {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 24px 0 32px;
}

.public-page .page-title {
    margin-top: 8px;
}

@media (max-width: 900px) {
    .container {
        width: calc(100% - 16px);
    }

    .page-content {
        padding-left: 0;
        padding-right: 0;
    }

    .card {
        padding: 16px;
    }
}

@media (max-width: 640px) {
    .container {
        width: calc(100% - 10px);
    }

    .public-page {
        padding: 8px 0 20px;
    }

    .card {
        padding: 14px;
        border-radius: 12px;
    }
}

.with-sidebar {
    display: block;
}

.sidebar {
    position: sticky;
    top: 18px;
    align-self: start;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.sidebar .sidebar-brand {
    padding: 20px 20px;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    background: var(--surface-variant);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.sidebar .sidebar-brand a {
    color: var(--text);
    display: inline-block;
}
.sidenav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}
.sidenav-link {
    display: block;
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 8px;
    border-radius: 16px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.sidenav-link:hover,
.sidenav-link.active {
    background: rgba(45,124,255,0.12);
    color: var(--brand-dark);
    transform: translateX(2px);
}
.sidenav-link.active {
    font-weight: 700;
}

/* Header and topnav removed in favor of sidebar-only navigation */

.sidebar .sidebar-brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    background: var(--surface-variant);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.sidebar .sidebar-brand a {
    color: var(--text);
    display: inline-block;
}

.sidebar-actions {
    display: inline-flex;
    gap: 8px;
}

.sidebar-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    line-height: 0;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-actions a svg {
    display: block;
    flex-shrink: 0;
    margin: 0 auto;
}

.sidebar-actions a:hover {
    background: var(--surface-strong);
    color: var(--brand);
}

.sidenav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 20px;
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-title h1 {
    margin: 0;
    font-size: clamp(1.8rem, 2.4vw, 2.6rem);
    letter-spacing: -0.02em;
}

.sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--surface-strong);
    color: var(--brand);
}

.sidebar-backdrop {
    display: none;
}

.page-title p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.7;
}

.page-content {
    padding: 0 0 24px;
}

.page-main.no-sidebar {
    width: 100%;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    align-items: start;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.card-grid .card {
    margin-bottom: 0;
}

.ingredient-row {
    align-items: end;
    grid-template-columns: 1.6fr 0.8fr 1fr auto;
}

.other-cost-row {
    align-items: end;
    grid-template-columns: 1.6fr 1fr auto;
}

.ingredient-row label {
    margin-bottom: 0;
}

.remove-ingredient,
.remove-other-cost {
    height: 44px;
    align-self: flex-end;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]):not([type="color"]):not([type="hidden"]),
select,
textarea {
    width: 100%;
    border: 1px solid #cfd8e7;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[readonly] {
    background: var(--surface-variant);
    color: var(--text-muted);
    cursor: not-allowed;
    font-weight: 600;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(45, 124, 255, 0.12);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.table {
    display: block;
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: #fff;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
}

.table th,
.table td {
    padding: 16px 18px;
    border-bottom: 1px solid #edf2f7;
    color: var(--text);
}

.table th {
    background: #f4f7fb;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.85rem;
    color: #4b5563;
}

.table tbody tr:hover {
    background: #f8fbff;
}

.table td:last-child,
.table th:last-child {
    text-align: right;
}

.menu-scroll {
    max-height: 480px;
    overflow-y: auto;
    border-radius: 16px;
}

.menu-scroll .table {
    display: table;
    overflow: visible;
    margin-top: 0;
}

.menu-scroll {
    overflow-x: auto;
}

.menu-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.2s ease;
    vertical-align: middle;
}

.toggle-switch.on {
    background: var(--success);
}

.toggle-switch .toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: left 0.2s ease;
}

.toggle-switch.on .toggle-knob {
    left: 22px;
}

.table-thumb,
.menu-image-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 9999;
}

.image-modal-content {
    position: relative;
    width: min(95%, 720px);
    max-height: 95%;
    background: var(--surface);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 26px 70px rgba(15, 23, 42, 0.35);
    overflow: auto;
}

.image-modal-content h3 {
    margin: 0 0 16px;
    font-size: 1.2rem;
}

.image-modal-content img {
    width: 100%;
    height: auto;
    border-radius: 18px;
    display: block;
}

.image-modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    background: rgba(255,255,255,0.9);
    border: none;
    color: var(--text);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.alert {
    padding: 16px 20px;
    border-radius: 14px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.alert.success {
    background: var(--success-soft);
    border: 1px solid rgba(26, 123, 52, 0.18);
    color: var(--success);
}

.alert.warning {
    background: var(--warning-soft);
    border: 1px solid rgba(179, 108, 0, 0.18);
    color: var(--warning);
}

.alert.danger {
    background: var(--danger-soft);
    border: 1px solid rgba(201, 42, 42, 0.18);
    color: var(--danger);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
}

.badge.success {
    color: #14532d;
    background: #dcfce7;
}

.badge.danger {
    color: #7f1d1d;
    background: #fee2e2;
}

footer.page-footer {
    padding: 20px 24px;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand a svg {
    flex-shrink: 0;
    color: var(--brand);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.sidebar-user-info strong {
    font-size: 0.92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: rgba(45, 124, 255, 0.12);
    color: var(--brand-dark);
}

.sidenav-link {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidenav-link svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.sidenav-link:hover svg,
.sidenav-link.active svg {
    color: var(--brand-dark);
}

@media (max-width: 900px) {
    .page-shell {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(300px, 85vw);
        max-width: 300px;
        margin: 0;
        border-radius: 0;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1000;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

@media (min-width: 901px) {
    body.sidebar-collapsed .sidebar {
        display: none;
    }

    body.sidebar-collapsed .page-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .table th,
    .table td {
        padding: 12px 10px;
    }

    .button,
    button {
        width: 100%;
    }
}

.store-banner {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    padding: 36px 32px;
    margin-bottom: 24px;
    color: #fff;
    box-shadow: var(--shadow);
}

.store-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.05));
    pointer-events: none;
}

.store-banner-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.store-logo-lg {
    width: 120px;
    height: 120px;
    object-fit: contain;
    background: #fff;
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.store-banner-text h1 {
    margin: 0 0 6px;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.store-banner-text p {
    margin: 0;
    opacity: 0.92;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

@media (max-width: 640px) {
    .store-banner {
        padding: 24px 18px;
        border-radius: 18px;
    }

    .store-banner-inner {
        gap: 16px;
    }

    .store-logo-lg {
        width: 84px;
        height: 84px;
        padding: 8px;
        border-radius: 14px;
    }

    .store-banner-text h1 {
        font-size: 1.5rem;
    }
}
