/* El Galego - Design System & Modern UI Stylesheet */

:root {
    --bg-dark: #121214;
    --bg-card: #18181B;
    --bg-card-hover: #27272A;
    --bg-input: #27272A;
    --border-color: #3F3F46;
    --border-highlight: #52525B;
    
    --primary: #D97706; /* Amber Gold */
    --primary-hover: #F59E0B;
    --primary-light: rgba(217, 119, 6, 0.15);
    
    --text-main: #FAFAFA;
    --text-muted: #A1A1AA;
    --text-dark: #18181B;

    --status-pending: #F59E0B;
    --status-finalized: #10B981;
    --danger: #EF4444;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
    --bg-dark: #F4F4F5;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F5F9;
    --bg-input: #F8FAFC;
    --border-color: #E4E4E7;
    --border-highlight: #CBD5E1;
    
    --primary: #D97706;
    --primary-hover: #B45309;
    --primary-light: rgba(217, 119, 6, 0.12);
    
    --text-main: #18181B;
    --text-muted: #71717A;
    --text-dark: #FFFFFF;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Header & Navbar */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-main);
}

.navbar-logo {
    height: 42px;
    width: auto;
    border-radius: 4px;
    object-fit: contain;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    background: var(--bg-card-hover);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-pill {
    background: var(--primary-light);
    color: var(--primary-hover);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Main Container */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: #fff;
}

.btn-secondary {
    background-color: var(--bg-card-hover);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
}

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

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.text-uppercase {
    text-transform: uppercase;
}

/* Cards & Grid */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

/* Tabs & Categories */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    scrollbar-width: thin;
}

.tab-btn {
    padding: 0.65rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn:hover, .tab-btn.active {
    background: var(--primary-light);
    color: var(--primary-hover);
    border-color: var(--primary);
}

/* Product Requisition Table / List */
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: border-color 0.2s;
}

.product-card:hover {
    border-color: var(--border-highlight);
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

.product-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-card-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

/* Quantity Control Widget */
.qty-control {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.qty-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.qty-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-icon-action {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    opacity: 0.85;
}

.btn-icon-action:hover {
    opacity: 1;
    transform: scale(1.08);
}

.btn-icon-action.action-btn-edit:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.btn-icon-action.action-btn-delete:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.qty-input {
    width: 70px;
    height: 38px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.qty-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-finalized {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-body {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

/* Discrete Top-Page Sync Status Badge (Non-obstructive) */
.sync-badge {
    position: fixed;
    top: 14px;
    right: 20px;
    z-index: 10050;
    padding: 0.45rem 1rem;
    border-radius: 30px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #ffffff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.sync-badge.active {
    opacity: 1;
    transform: translateY(0);
}

.sync-badge.sync-saving {
    background: #2563eb;
}

.sync-badge.sync-success {
    background: #15803d;
}

.sync-badge.sync-error {
    background: #b91c1c;
}

/* Messages Alert */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Responsive adjustments for Mobile & Tablets */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }
    
    /* Header & Navbar Mobile Optimization */
    .navbar {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
        justify-content: flex-start;
    }
    
    .navbar-logo {
        height: 36px;
    }
    
    .navbar-user {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .user-badge {
        flex: 1 1 100%;
        justify-content: space-between;
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    .navbar-user .btn {
        flex: 1;
        font-size: 0.8rem;
        padding: 0.45rem 0.6rem;
        white-space: nowrap;
        text-align: center;
    }
    
    /* Horizontal Scrollable Tabs & Category Pills */
    .category-tabs {
        display: flex;
        gap: 0.4rem;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }
    
    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 0.55rem 0.9rem;
        font-size: 0.82rem;
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Cards & Section Headers */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-sm);
    }
    
    .product-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.85rem;
    }
    
    .product-info {
        width: 100%;
    }

    .product-name {
        font-size: 0.95rem;
        word-break: break-word;
    }
    
    /* Touch-friendly Quantity Control Stepper */
    .qty-control {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .qty-btn {
        flex: 1;
        max-width: 70px;
        height: 44px;
        font-size: 1.3rem;
        border-radius: 8px;
    }

    .qty-input {
        flex: 2;
        max-width: none;
        height: 44px;
        font-size: 1.15rem;
        border-radius: 8px;
    }

    .btn-icon-action {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }
    
    .grid-3, .grid-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* ================= PRINT A4 STYLES ================= */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt;
    }

    .no-print, .navbar, .btn, .category-tabs {
        display: none !important;
    }

    .print-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }

    .print-logo {
        height: 60px;
        width: auto;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
    }

    .print-table th, .print-table td {
        border: 1px solid #333;
        padding: 6px 10px;
        text-align: left;
    }

    .print-table th {
        background-color: #eee !important;
        color: #000 !important;
        font-weight: bold;
        text-transform: uppercase;
    }

    .checkbox-col {
        width: 40px;
        text-align: center;
    }

    .check-box-square {
        display: inline-block;
        width: 16px;
        height: 16px;
        border: 2px solid #000;
    }
}

/* Backoffice Real-Time Auto-Sync Styles */
@keyframes syncPulse {
    0% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pulse-indicator {
    animation: syncPulse 2s infinite;
}

.pulse-indicator.paused {
    animation: none !important;
    background-color: var(--text-muted, #6b7280) !important;
}

