/* Toadee Admin UI - Brand Colors */
:root {
    --green-primary: #5B8C3E;
    --green-dark: #2D4A1F;
    --green-accent: #7AB556;
    --green-light: #E8F0E2;
    --bg-light: #F5F7F3;
    --bg-white: #FFFFFF;
    --text-dark: #1A1A1A;
    --text-muted: #6B7280;
    --border: #D1D5DB;
    --danger: #D32F2F;
    --danger-light: #FDECEA;
    --warning: #F9A825;
    --warning-light: #FFF8E1;
    --blue: #1976D2;
    --blue-light: #E3F2FD;
    --sidebar-width: 250px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
}

/* Admin Shell */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--green-dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo img {
    max-width: 160px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--green-primary);
    color: white;
    font-weight: 600;
}

.nav-icon { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 8px 0;
}

.sidebar-footer .logout { color: rgba(255,255,255,0.5); }
.sidebar-footer .logout:hover { color: #ff8a80; background: rgba(255,0,0,0.1); }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

/* Login */
.login-shell {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-light);
}

.login-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    text-align: center;
}

.login-logo { max-width: 180px; margin-bottom: 24px; }

.login-card h2 {
    margin-bottom: 24px;
    color: var(--green-dark);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 3px rgba(91,140,62,0.15);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green-primary); color: white; }
.btn-primary:hover { background: var(--green-accent); }
.btn-secondary { background: #E5E7EB; color: var(--text-dark); }
.btn-secondary:hover { background: #D1D5DB; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #B71C1C; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }
.btn-full { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 4px 8px; font-size: 1.2rem; border-radius: 4px; }
.btn-icon:hover { background: rgba(0,0,0,0.05); }
.btn-remove { color: var(--danger); position: absolute; top: 4px; right: 4px; background: white; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #E5E7EB;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 { font-size: 1.1rem; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #E5E7EB;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--green-primary);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    color: var(--green-dark);
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
}

.data-table th {
    background: var(--bg-light);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:hover { background: #F9FAFB; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-yellow { background: var(--warning-light); color: #E65100; }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-gray { background: #F3F4F6; color: #6B7280; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #FFCDD2; }
.alert-success { background: var(--green-light); color: var(--green-dark); border: 1px solid #C8E6C9; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-content h3 { margin-bottom: 12px; color: var(--green-dark); }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Image Upload */
.image-upload { margin-bottom: 16px; }

.drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 32px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}

.drop-zone:hover, .drop-zone.dragging {
    border-color: var(--green-primary);
    background: var(--green-light);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-text { color: var(--text-muted); font-size: 0.9rem; }

.image-preview {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.image-preview img { max-width: 200px; max-height: 150px; display: block; }

/* Server Info Box */
.server-info {
    background: var(--green-dark);
    color: white;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.server-info h3 { margin-bottom: 12px; font-size: 1.1rem; }

.ip-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.ip-entry:last-child { border-bottom: none; }

.ip-address {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--green-accent);
}

.ip-label { font-size: 0.85rem; color: rgba(255,255,255,0.6); }

.copy-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.copy-btn:hover { background: rgba(255,255,255,0.25); }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.toast-success { background: var(--green-primary); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--blue); color: white; }

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

/* Two-panel layout (for menu management) */
.two-panel {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    min-height: calc(100vh - 120px);
}

/* Category Tree */
.category-tree { padding: 8px 0; }

.tree-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.tree-item:hover { background: var(--green-light); }
.tree-item.selected { background: var(--green-light); border-left: 3px solid var(--green-primary); font-weight: 600; }

.tree-children { padding-left: 20px; }

.tree-item-image { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }

/* Item Grid */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.item-card {
    background: var(--bg-white);
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.item-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.item-card.unavailable { opacity: 0.5; }

.item-card-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: #F3F4F6;
}

.item-card-body { padding: 12px; }

.item-card-name { font-weight: 600; margin-bottom: 4px; }

.item-card-price {
    color: var(--green-primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.item-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid #E5E7EB;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #CBD5E1;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Kanban Board */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    min-height: calc(100vh - 180px);
}

.kanban-column {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 16px;
}

.kanban-column-header {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-count {
    background: var(--bg-white);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.order-card {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    border-left: 4px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.order-card.urgency-green { border-left-color: var(--green-primary); }
.order-card.urgency-yellow { border-left-color: var(--warning); }
.order-card.urgency-orange { border-left-color: #FF9800; }
.order-card.urgency-red { border-left-color: var(--danger); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
    50% { box-shadow: 0 1px 12px rgba(211,47,47,0.3); }
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.order-table-number { font-size: 1.4rem; font-weight: 800; }
.order-elapsed { font-size: 0.85rem; color: var(--text-muted); font-family: monospace; }
.order-items { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }

/* Urgency progress bar */
.urgency-bar {
    height: 4px;
    border-radius: 2px;
    background: #E5E7EB;
    margin-bottom: 10px;
    overflow: hidden;
}

.urgency-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 1s linear, background 1s linear;
}

/* Connection dot */
.connection-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.connection-dot.online { background: var(--green-primary); }
.connection-dot.reconnecting { background: var(--warning); }
.connection-dot.offline { background: var(--danger); }

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-12 { gap: 12px; }
.inline-flex { display: inline-flex; align-items: center; }
.gap-8 { gap: 8px; }

/* ─── QR Print Cards (screen: hidden, print: visible) ─── */
.qr-print-container { display: none; }

.qr-print-card {
    text-align: center;
    padding: 32px 24px;
    border: 2px solid #5B8C3E;
    border-radius: 12px;
    page-break-inside: avoid;
    break-inside: avoid;
}
.qr-print-brand { margin-bottom: 16px; }
.qr-print-logo { height: 48px; width: auto; }
.qr-print-qr { display: block; margin: 0 auto 16px; }
.qr-print-table {
    font-size: 28px;
    font-weight: 800;
    color: #333;
    margin-bottom: 4px;
}
.qr-print-instruction {
    font-size: 16px;
    color: #5B8C3E;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ─── Print Stylesheet ─── */
@media print {
    /* Hide everything on screen */
    body > *:not(.qr-print-container),
    .sidebar,
    .main-content,
    nav,
    header,
    .page-header { display: none !important; }

    /* Show the print container */
    .qr-print-container {
        display: block !important;
        position: fixed;
        inset: 0;
        z-index: 99999;
        background: white;
        padding: 0;
        margin: 0;
    }

    /* 2x2 grid for Print All */
    .qr-print-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        padding: 24px;
    }
    .qr-print-grid .qr-print-qr { width: 200px; height: 200px; }
    .qr-print-grid .qr-print-table { font-size: 24px; }

    /* Full page for single print */
    .qr-print-single {
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
    }
    .qr-print-single .qr-print-card {
        padding: 48px 64px;
        border-width: 3px;
    }
    .qr-print-single .qr-print-logo { height: 64px; }
    .qr-print-single .qr-print-qr { width: 300px; height: 300px; }
    .qr-print-single .qr-print-table { font-size: 36px; }
    .qr-print-single .qr-print-instruction { font-size: 20px; }

    /* Clean up print */
    .qr-print-card { border-color: #333; }
    @page { margin: 0.5in; }
}
