:root {
    /* Paleta Principal - Identidad Il Cuoco */
    --color-primary: #d4af37;        /* Dorado/Amber Premium */
    --color-primary-dark: #b5952f;
    --color-primary-light: rgba(212, 175, 55, 0.15);
    
    --color-secondary: #0a1710;      /* Verde Institucional Profundo (Fondo) */
    --color-surface: rgba(22, 51, 35, 0.65); /* Verde Tarjetas */
    --color-surface-hover: rgba(33, 77, 52, 0.85);
    
    /* Estados Semánticos */
    --color-success: #10b981;        /* Esmeralda */
    --color-warning: #f59e0b;        /* Ámbar */
    --color-danger: #ef4444;         /* Rojo */
    --color-danger-hover: #dc2626;
    --color-info: #3b82f6;           /* Azul */
    
    /* Textos y Bordes */
    --color-text: #f4f6f0;           /* Crema / Blanco roto */
    --color-text-muted: #aebdb5;     /* Gris verdoso */
    --color-border: rgba(244, 246, 240, 0.08);
    
    /* Tipografía */
    --font-heading: 'Barlow Condensed', sans-serif;
    --font-body: 'Poppins', sans-serif;
    
    /* Radios */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-pill: 9999px;
    
    /* Sombras */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Espaciados */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Layout metrics */
    --sidebar-width: 230px;
    --header-height: 60px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-secondary);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    font-size: 0.9rem; /* Reduced base font size */
}

h1, h2, h3, h4, h5, h6, .page-title, .sidebar-brand {
    font-family: var(--font-heading);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--color-primary-dark);
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 23, 16, 0.95);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1045; /* Above navbar for mobile */
    transition: var(--transition);
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show-mobile {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-brand {
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span {
    background: linear-gradient(135deg, #fff 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 1.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition);
}

.sidebar-link:hover, .sidebar-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 4px 0 0 var(--color-primary);
}

.sidebar-link.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px 14px;
    border-radius: var(--border-radius-md);
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--header-height);
    background: rgba(10, 23, 16, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.content-body {
    padding: 2rem;
    flex-grow: 1;
}

/* Grid System */
.grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.grid-1 { grid-template-columns: 1fr; }

/* Dashboard Cards (KPI) */
.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(245, 158, 11, 0.3);
    background: var(--color-surface-hover);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 5px 0;
}

.kpi-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.kpi-icon {
    font-size: 2.2rem;
    opacity: 0.8;
}

/* Standard Content Card */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.75rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 8px 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
    vertical-align: middle;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.form-control, .form-select, select, textarea {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    color: #fff;
    font-size: 16px; /* 16px to prevent iOS auto-zoom */
    font-family: inherit;
    transition: var(--transition);
    min-height: 44px; /* Mobile touch target size */
}

.form-control:focus, .form-select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    border: none;
    min-height: 44px; /* Mobile touch target size */
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #0b0f17;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--border-radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-efectivo { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-qr { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.badge-transferencia { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-debito { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.badge-credito { background: rgba(236, 72, 153, 0.15); color: #f472b6; }

/* Responsive adjustments */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
}


/* Tienda Specific Components */
.navbar-tienda {
    background: rgba(10, 23, 16, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
}
.card-producto {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    transition: var(--transition);
}
.card-producto:hover {
    transform: translateY(-5px);
    border-color: rgba(212, 175, 55, 0.4);
}
.producto-img-container {
    width: 100%;
    height: 200px;
    background-color: rgba(0,0,0,0.2);
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.producto-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}
.cart-badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(50%, -50%);
}

/* Submenu Styles */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
}
.sidebar-submenu.show {
    display: block;
}
.sidebar-submenu .sidebar-link {
    padding-left: 2.5rem;
    font-size: 0.9em;
}
.submenu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.submenu-arrow {
    font-size: 0.8em;
    transition: transform 0.2s ease;
}
.submenu-toggle.open .submenu-arrow {
    transform: rotate(180deg);
}

/* Sidebar and Header Utilities */
.sidebar-logo {
    height: 44px;
    width: auto;
    max-width: 100%;
    border-radius: var(--border-radius-sm);
    object-fit: contain;
    box-shadow: var(--shadow-sm);
}
.sidebar-logo-sm {
    height: 32px;
    border-radius: 4px;
    margin-right: 8px;
}
.sidebar-brand-text {
    color: var(--color-text);
    background: none;
    -webkit-text-fill-color: initial;
}
.sidebar-user-role {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.sidebar-user-name {
    font-size: 0.9rem;
    font-weight: bold;
}
.sidebar-user-title {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}
.btn-icon-only {
    width: 44px;
    min-height: 44px;
    padding: 6px 12px;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-logout {
    min-height: 44px;
    padding: 0 16px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
}

/* Form and Button Accessibility */
.btn, .form-control, .form-select, .input-group-text {
    min-height: 44px; /* Minimum touch target */
}
.btn-sm, .form-control-sm, .form-select-sm {
    min-height: 36px;
}
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--color-text);
}
.table-responsive {
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: var(--spacing-md);
}

/* Bootstrap Color Overrides */
:root {
    --bs-primary: var(--color-primary);
    --bs-primary-rgb: 212, 175, 55;
    --bs-success: var(--color-success);
    --bs-success-rgb: 16, 185, 129;
    --bs-danger: var(--color-danger);
    --bs-danger-rgb: 239, 68, 68;
    --bs-warning: var(--color-warning);
    --bs-warning-rgb: 245, 158, 11;
    --bs-info: var(--color-info);
    --bs-info-rgb: 59, 130, 246;
}
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-info { color: var(--color-info) !important; }
.text-muted { color: var(--color-text-muted) !important; }

/* Backward Compatibility Aliases for Inline Styles */
:root {
    --primary: var(--color-primary);
    --secondary: var(--color-success);
    --danger: var(--color-danger);
    --warning: var(--color-warning);
    --info: var(--color-info);
    --bg-color: var(--color-secondary);
    --card-bg: var(--color-surface);
    --text-color: var(--color-text);
    --text-muted: var(--color-text-muted);
    --border-color: var(--color-border);
}

/* Fix for dropdown options visibility */
select option {
    background-color: var(--color-secondary);
    color: var(--color-text);
}
