/**
 * RTEC - Estilos Principales
 * Sistema de Gestión de Celulares y Accesorios
 */

/* ============================================
   VARIABLES Y RESET
   ============================================ */
:root {
    /* Colores principales */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    
    --success: #10b981;
    --success-dark: #059669;
    --success-light: #34d399;
    
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #f87171;
    
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --warning-light: #fbbf24;
    
    --info: #06b6d4;
    --info-dark: #0891b2;
    --info-light: #22d3ee;
    
    /* Grises */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Layout */
    --header-height: 70px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    
    /* Fuentes */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transiciones */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Autocomplete de búsquedas
   ============================================ */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-md);
    border-radius: 0.5rem;
    margin-top: 4px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 20;
}

.autocomplete-item {
    padding: 10px 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.autocomplete-item:hover {
    background: var(--gray-50);
}

.autocomplete-title {
    font-weight: 600;
    color: var(--gray-800);
}

.autocomplete-meta {
    font-size: 12px;
    color: var(--gray-500);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.autocomplete-estado {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ecfeff;
    color: #0ea5e9;
}

.autocomplete-estado.vendido {
    background: #fee2e2;
    color: #b91c1c;
}

.autocomplete-empty {
    padding: 10px 12px;
    color: var(--gray-500);
    font-size: 13px;
}

/* ============================================
   Modal de detalle rápido
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 18px;
    max-width: 960px;
    width: 90%;
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 18px;
}

.modal-photo img {
    width: 100%;
    border-radius: 10px;
    object-fit: cover;
    min-height: 260px;
    background: var(--gray-100);
}

.modal-info h2 {
    margin: 0;
    font-size: 24px;
    color: var(--gray-800);
}

.modal-info .mono {
    font-family: monospace;
    color: #0ea5e9;
    margin: 4px 0 10px 0;
}

.modal-info .small {
    font-size: 13px;
    color: var(--gray-600);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.meta-grid .label {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-grid strong {
    color: var(--gray-800);
    font-weight: 700;
}

@media (max-width: 768px) {
    .modal-grid {
        grid-template-columns: 1fr;
    }
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background-color: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ============================================
   HEADER
   ============================================ */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}

.toggle-sidebar:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 1.75rem;
}

.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
}

.search-bar {
    position: relative;
    width: 100%;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.caja-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.caja-status.activa {
    background: #d1fae5;
    color: var(--success-dark);
}

/* Notificaciones */
.notifications {
    position: relative;
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}

.notification-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.notification-btn .badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 999px;
    font-weight: 600;
}

/* Usuario */
.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}

.user-btn:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-btn img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
    z-index: 1000;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.user-info {
    padding: 1rem;
}

.user-name {
    font-weight: 600;
    color: var(--gray-800);
}

.user-role {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: var(--transition);
}

.user-dropdown a:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.user-dropdown hr {
    margin: 0.5rem 0;
    border: none;
    border-top: 1px solid var(--gray-200);
}

.logout-btn {
    color: var(--danger) !important;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    z-index: 90;
    transition: var(--transition);
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 1rem 1.5rem 0.5rem;
}

.nav-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

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

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-dark);
}

.badge-count,
.badge-alert,
.badge-new {
    margin-left: auto;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-count {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-alert {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-new {
    background: var(--success-light);
    color: var(--success-dark);
}

.sidebar-footer {
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
}

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash-message {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    right: 1rem;
    background: white;
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

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

.flash-message i {
    font-size: 1.5rem;
}

.flash-success {
    border-left: 4px solid var(--success);
    color: var(--success-dark);
}

.flash-success i {
    color: var(--success);
}

.flash-error {
    border-left: 4px solid var(--danger);
    color: var(--danger-dark);
}

.flash-error i {
    color: var(--danger);
}

.flash-warning {
    border-left: 4px solid var(--warning);
    color: var(--warning-dark);
}

.flash-warning i {
    color: var(--warning);
}

.close-flash {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0.25rem;
    margin-left: auto;
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-dark);
}

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

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-admin {
    background: var(--primary-light);
    color: white;
}

.badge-vendedor {
    background: var(--info-light);
    color: white;
}

.badge-encargado {
    background: var(--success-light);
    color: white;
}

.badge-contabilidad {
    background: var(--warning-light);
    color: var(--warning-dark);
}

/* ============================================
   UTILIDADES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-red { color: var(--danger); }

.font-bold { font-weight: 600; }

.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 80;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .header-center {
        display: none;
    }
}
