@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

:root {
    --bg-primary: #090d16;
    --bg-secondary: #121824;
    --bg-glass: rgba(20, 27, 41, 0.65);
    --border-glass: rgba(255, 255, 255, 0.07);
    --border-glass-focus: rgba(217, 119, 6, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent: #d97706; /* Cafe Gold */
    --accent-hover: #b45309;
    --accent-light: #f59e0b;
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --font-sans: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(217, 119, 6, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.04) 0%, transparent 40%);
    background-attachment: fixed;
    padding: 20px;
    min-height: 100vh;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Glass Card Component */
.glass-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 24px;
    transition: var(--transition);
}
.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 2px solid var(--accent);
}
.logo-container {
    display: flex;
    align-items: center;
    gap: 16px;
}
.app-logo {
    height: 70px;
    width: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    background-color: #ffffff;
    padding: 4px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.app-logo:hover {
    transform: scale(1.03);
    border-color: var(--accent-light);
}
.app-title h1 {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.app-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Metadata Form (Service, Date, Hour) */
.metadata-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
@media (max-width: 768px) {
    .metadata-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
}
.input-field {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition);
    width: 100%;
}
.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--border-glass-focus);
}

/* Stats / Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
.stat-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}
.stat-card.success::after { background: var(--success); }
.stat-card.danger::after { background: var(--danger); }
.stat-card.warning::after { background: var(--warning); }

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 500;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-sans);
}

/* Product list / Form Table */
.table-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.table-header-bar h2 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
}
.btn {
    background: var(--accent);
    color: var(--text-primary);
    border: none;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}
.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}
.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}
.product-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 600px;
}
.product-table th {
    background: rgba(15, 23, 42, 0.8);
    padding: 14px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-glass);
}
.product-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(20, 27, 41, 0.3);
    vertical-align: middle;
}
.product-table tr:hover td {
    background: rgba(30, 41, 59, 0.3);
}

/* Autocomplete Suggestion Dropdown */
.autocomplete-container {
    position: relative;
    width: 100%;
}
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
}
.autocomplete-item:hover {
    background: var(--accent);
    color: white;
}

/* Row states */
.row-mismatch td {
    background-color: var(--danger-light) !important;
}
.row-mismatch input {
    border-color: rgba(239, 68, 68, 0.4);
}
.row-match td {
    background-color: var(--success-light) !important;
}
.row-match input {
    border-color: rgba(16, 185, 129, 0.4);
}

.table-input {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
    font-family: var(--font-sans);
    transition: var(--transition);
}
.table-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Signature & Satisfaction Section */
.footer-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 768px) {
    .footer-sections-grid {
        grid-template-columns: 1fr;
    }
}

.section-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Satisfaction Smileys */
.satisfaction-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(30, 41, 59, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    height: 180px;
}
.smiley-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 3.5rem;
    filter: grayscale(100%) opacity(40%);
    transition: var(--transition);
    outline: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.smiley-btn span {
    font-size: 0.8rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
}
.smiley-btn.active.happy {
    filter: grayscale(0%) scale(1.15);
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}
.smiley-btn.active.happy span {
    color: var(--success);
}
.smiley-btn.active.sad {
    filter: grayscale(0%) scale(1.15);
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}
.smiley-btn.active.sad span {
    color: var(--danger);
}
.smiley-btn:hover {
    filter: grayscale(50%) opacity(80%) scale(1.05);
}

/* Signature Pad Canvas */
.signature-box {
    background: white; /* Match paper background */
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    position: relative;
    height: 180px;
    overflow: hidden;
}
#signature-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}
.sig-clear-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-primary);
    border: none;
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: var(--transition);
}
.sig-clear-btn:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Role Selector and Mode styling */
.role-selector {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 4px;
}
@media (max-width: 600px) {
    .table-header-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    .role-selector {
        width: 100%;
    }
    .role-btn {
        flex: 1;
        text-align: center;
    }
}
.role-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.role-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}
.role-btn.active {
    color: var(--text-primary);
    background: var(--accent);
}

/* Hide rows and disable inputs based on role */
.row-hidden {
    display: none !important;
}

/* Visually dim delivered qty in Chef mode to focus on ordering */
.mode-chef .qty-delivered-input {
    opacity: 0.3;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.2);
}

/* Visually dim requested qty in Economat mode since it's verified */
.mode-economat .qty-requested-input {
    opacity: 0.7;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.2);
}

/* Action controls bar */
.actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}
@media (max-width: 480px) {
    .actions-bar {
        justify-content: stretch;
    }
    .actions-bar .btn {
        flex: 1 1 100%;
        text-align: center;
        justify-content: center;
    }
}

/* Excel Importer Tool UI */
.importer-zone {
    border: 2px dashed rgba(217, 119, 6, 0.3);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: rgba(217, 119, 6, 0.02);
}
.importer-zone:hover {
    border-color: var(--accent);
    background: rgba(217, 119, 6, 0.05);
}
.importer-zone p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.importer-zone strong {
    color: var(--accent-light);
}
.hidden-file-input {
    display: none;
}

/* History Viewer */
.history-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.history-item {
    background: rgba(30, 41, 59, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}
.history-item:hover {
    background: rgba(30, 41, 59, 0.35);
}
.history-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.history-date {
    font-weight: 600;
    font-size: 1rem;
}
.history-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.history-actions {
    display: flex;
    gap: 8px;
}

/* Firebase Connection Badges and Statuses */
.status-badge {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-badge.local {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.3);
}
.status-badge.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.4);
}
.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

/* History Item Status Badges */
.history-status-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    margin-left: 8px;
    border: 1px solid transparent;
}
.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
}
.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

/* Login Overlay Styling */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 6, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 36px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
.logo-box-auth {
    border: 2px solid var(--text-primary);
    padding: 8px 16px;
    text-align: center;
    font-family: var(--font-serif);
    font-size: 1.3rem;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #2a1f15 0%, #17110c 100%);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    margin: 0 auto 24px auto;
    width: fit-content;
}
.logo-box-auth span {
    display: block;
    font-size: 0.65rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    color: var(--accent-light);
    margin-top: 2px;
    font-weight: bold;
}
.login-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 500;
}

/* User Profile Banner styles */
.profile-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
}

/* Status Badge Roles style overrides */
.status-badge.admin {
    background: rgba(217, 119, 6, 0.15) !important;
    color: var(--accent-light) !important;
    border: 1px solid rgba(217, 119, 6, 0.3) !important;
}
.status-badge.chef, .status-badge.barman {
    background: rgba(245, 158, 11, 0.15) !important;
    color: var(--warning) !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}
.status-badge.economat {
    background: rgba(16, 185, 129, 0.15) !important;
    color: var(--success) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}

/* Hide components based on authentication role policy */
.user-role-restricted-view {
    display: none !important;
}

/* Print Styling to EXACTLY mimic the paper slip */
@media print {
    body {
        background: white !important;
        color: black !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 12pt;
    }
    
    .app-container {
        max-width: 100% !important;
        gap: 0 !important;
    }
    
    /* Hide all web components that are not needed on paper */
    .glass-card {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        margin: 0 0 10mm 0 !important;
    }
    
    .stats-grid,
    .importer-zone,
    .actions-bar,
    .history-section,
    .btn,
    .role-selector,
    .sig-clear-btn,
    .smiley-btn span,
    th:last-child, /* Hide actions columns */
    td:last-child {
        display: none !important;
    }
    
    /* Paper slip logo and structure style */
    .app-header {
        border-bottom: 1.5pt solid black !important;
        padding: 0 0 5mm 0 !important;
        margin-bottom: 5mm !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    .app-logo {
        height: 18mm !important;
        width: auto !important;
        border: 1pt solid black !important;
        background: white !important;
        padding: 1mm !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    .app-title h1 {
        -webkit-text-fill-color: black !important;
        color: black !important;
        font-size: 22pt !important;
    }
    
    /* Form metadata */
    .metadata-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5mm !important;
        border: 1pt solid black !important;
        padding: 3mm !important;
        margin-bottom: 5mm !important;
    }
    .input-group label {
        color: black !important;
        font-weight: bold !important;
        font-size: 9pt !important;
    }
    .input-field {
        background: none !important;
        border: none !important;
        border-bottom: 1px dotted black !important;
        color: black !important;
        padding: 2px !important;
        border-radius: 0 !important;
    }
    
    /* Paper table style */
    .table-wrapper {
        border: none !important;
    }
    .product-table {
        min-width: 100% !important;
    }
    .product-table th,
    .product-table td {
        border: 1px solid black !important;
        background: none !important;
        color: black !important;
        padding: 6px 10px !important;
    }
    .product-table th {
        font-weight: bold !important;
        text-align: center !important;
        font-size: 10pt !important;
    }
    .product-table td input {
        border: none !important;
        background: none !important;
        color: black !important;
        text-align: center !important;
    }
    
    /* Footer details */
    .footer-sections-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10mm !important;
        margin-top: 8mm !important;
        border-top: 1.5pt solid black !important;
        padding-top: 5mm !important;
    }
    
    .satisfaction-container {
        border: 1pt solid black !important;
        background: none !important;
        height: auto !important;
        padding: 4mm !important;
    }
    .smiley-btn {
        filter: none !important;
        font-size: 24pt !important;
        color: black !important;
        opacity: 0.2 !important;
    }
    .smiley-btn.active {
        opacity: 1.0 !important;
        filter: none !important;
    }
    
    .signature-box {
        border: 1pt solid black !important;
        background: white !important;
        height: 35mm !important;
    }
}
