/* ========================================
   INVENTARIO TIENDA - ESTILOS PRINCIPALES
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --radius: 12px;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
    min-height: 100vh;
    color: var(--dark);
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, #0f172a 100%);
    padding: 20px 0;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    padding: 10px 20px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.sidebar-header h2 {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
}

.sidebar-header small {
    color: var(--secondary);
    font-size: 0.75rem;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin: 4px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-link:hover, .nav-link.active {
    background: rgba(37, 99, 235, 0.2);
    color: #fff;
}

.nav-link.active {
    background: var(--primary);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 20px 12px;
}

.user-info .nav-link {
    background: rgba(255,255,255,0.05);
    font-size: 0.85rem;
}

.user-info .nav-link i {
    color: #3b82f6;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
}

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

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
}

/* ========== CARDS ========== */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}

.stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-icon.green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    color: var(--secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ========== TABLE ========== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--light);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
}

tr:hover {
    background: #f8fafc;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

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

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

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== BADGES ========== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ========== SEARCH BOX ========== */
.search-box {
    position: relative;
    max-width: 300px;
}

.search-box input {
    padding-left: 40px;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--light);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: var(--secondary);
    transition: all 0.2s;
}

.tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow);
}

/* ========== ALERTS ========== */
.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* ========== RESPONSIVE ========== */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #dashboard .card-body table th,
    #dashboard .card-body table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 260px;
        left: -260px;
        transition: left 0.3s ease;
        z-index: 1001;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
        padding-top: 70px;
    }
    
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--dark);
        align-items: center;
        padding: 0 15px;
        z-index: 999;
        box-shadow: var(--shadow);
    }
    
    .menu-toggle {
        background: none;
        border: none;
        color: #fff;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 10px;
        margin-right: 15px;
    }
    
    .mobile-header h2 {
        color: #fff;
        font-size: 1.1rem;
        font-weight: 600;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .page-header > div {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .page-title {
        font-size: 1.4rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .stat-info h3 {
        font-size: 1.4rem;
    }
    
    .stat-info p {
        font-size: 0.75rem;
    }
    
    #dashboard > div:last-child {
        grid-template-columns: 1fr !important;
    }
    
    .card {
        border-radius: 10px;
    }
    
    .card-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .card-body {
        padding: 10px;
    }
    
    /* Tablas responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    th, td {
        padding: 12px 10px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    /* Tablas en cards móviles */
    .mobile-cards {
        display: none;
    }
    
    /* Botones */
    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }
    
    .btn-sm {
        padding: 8px 10px;
        width: auto;
    }
    
    .actions {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .btn-icon {
        width: 34px;
        height: 34px;
    }
    
    /* Modales */
    .modal {
        width: 95%;
        max-height: 85vh;
        margin: 10px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-control {
        padding: 14px 12px;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    /* Alertas */
    .alert {
        padding: 12px 15px;
        font-size: 0.85rem;
    }
    
    /* Plantillas */
    .plantilla-preview {
        font-size: 0.85rem;
        padding: 15px;
    }
    
    /* Toast */
    .toast-container {
        left: 10px;
        right: 10px;
        top: 70px;
    }
    
    .toast {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
}

/* Mobile pequeño */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        flex-direction: row;
        text-align: left;
    }
    
    .page-title {
        font-size: 1.2rem;
    }
    
    table {
        min-width: 500px;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 0.8rem;
    }
    
    .nav-link {
        padding: 14px 16px;
    }
}

/* Ocultar elementos en desktop */
.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* Fix para iOS */
@supports (-webkit-touch-callout: none) {
    .modal-overlay {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card {
    animation: fadeIn 0.3s ease-out;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
}

.toast {
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

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

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

/* ========== PLANTILLA PREVIEW ========== */
.plantilla-preview {
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-top: 10px;
    white-space: pre-wrap;
}

/* ========== ACTIONS ========== */
.actions {
    display: flex;
    gap: 8px;
}

/* ========== LOADING ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
