/*=====================================================
    Bulls System - Inventario y Ventas
    Custom Styles (Tailwind CSS companion)
======================================================*/

/* ============ Base ============ */
body, html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background-color: #f1f5f9;
}

/* ============ Scrollbars ============ */
.custom-scroll::-webkit-scrollbar { width: 6px; }
.custom-scroll::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }
.custom-scroll::-webkit-scrollbar-track { background: #1e293b; }

/* ============ Page Layout ============ */
.page-container {
    height: 100vh;
    width: 100%;
    display: flex;
    position: relative;
}

/* ============ Sidebar ============ */
.sidebar {
    width: 270px;
    min-width: 270px;
    background-color: #1e293b;
    color: #cbd5e1;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 40;
}
.sidebar.sidebar-hidden {
    width: 0;
    min-width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: #94a3b8;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    margin: 0.125rem 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
}
.sidebar-link:hover {
    background-color: #334155;
    color: #e2e8f0;
}
.sidebar-link.active {
    background-color: #4f46e5;
    color: #ffffff;
}
.sidebar-section-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.625rem 1rem;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    margin: 0.125rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: none;
    border: none;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.sidebar-section-btn:hover {
    background-color: #334155;
}
.sidebar-section-btn .chevron {
    transition: transform 0.3s ease;
    font-size: 0.75rem;
}
.sidebar-section-btn.open .chevron {
    transform: rotate(180deg);
}
.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-submenu.open {
    max-height: 500px;
}

/* ============ Main Content ============ */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    background-color: #f1f5f9;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ Top Navbar ============ */
.top-navbar {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ============ Cards & Stats ============ */
.stat-card {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}
.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* ============ Tables ============ */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.data-table thead th {
    background-color: #f8fafc;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
}
.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    color: #334155;
}
.data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* ============ Forms ============ */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #1e293b;
    background: #ffffff;
    transition: all 0.2s ease;
    outline: none;
    font-family: 'Inter', system-ui, sans-serif;
}
.form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.375rem;
}
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #1e293b;
    background: #ffffff;
    outline: none;
    font-family: 'Inter', system-ui, sans-serif;
    transition: all 0.2s ease;
}
.form-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    font-family: 'Inter', system-ui, sans-serif;
}
.btn-primary {
    background-color: #4f46e5;
    color: #ffffff;
}
.btn-primary:hover {
    background-color: #4338ca;
}
.btn-success {
    background-color: #059669;
    color: #ffffff;
}
.btn-success:hover {
    background-color: #047857;
}
.btn-danger {
    background-color: #dc2626;
    color: #ffffff;
}
.btn-danger:hover {
    background-color: #b91c1c;
}
.btn-warning {
    background-color: #d97706;
    color: #ffffff;
}
.btn-warning:hover {
    background-color: #b45309;
}
.btn-light {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.btn-light:hover {
    background-color: #e2e8f0;
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* ============ Badges ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success { background-color: #dcfce7; color: #166534; }
.badge-danger { background-color: #fee2e2; color: #991b1b; }
.badge-warning { background-color: #fef3c7; color: #92400e; }
.badge-info { background-color: #dbeafe; color: #1e40af; }

/* ============ Alerts ============ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.alert-success { background-color: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background-color: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ============ Pagination ============ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 0;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #475569;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}
.pagination a:hover {
    background-color: #f1f5f9;
    border-color: #6366f1;
    color: #4f46e5;
}
.pagination .active {
    background-color: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}
.pagination .disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ============ Modal ============ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.is-active {
    display: flex;
}
.modal-card {
    background: #ffffff;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.modal-body {
    padding: 1.5rem;
}

/* ============ Login Page ============ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #312e81 50%, #4f46e5 100%);
}

/* ============ Sidebar Overlay ============ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
}

/* ============ Sidebar Close Button (hidden on desktop) ============ */
.sidebar-close-btn {
    display: none;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 270px;
        min-width: 270px;
        opacity: 0;
        pointer-events: none;
        z-index: 50;
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }
    .sidebar.sidebar-visible {
        left: 0;
        opacity: 1;
        pointer-events: auto;
    }
    .sidebar-close-btn {
        display: flex;
    }
    .main-content {
        width: 100%;
    }
    .top-navbar {
        padding: 0 1rem;
    }
    .top-navbar h2 {
        font-size: 0.75rem;
    }
    /* Content padding */
    #contentWrapper {
        padding: 1rem !important;
    }
    /* Stat cards */
    .stat-card {
        padding: 1rem;
    }
    /* Forms */
    .form-input, .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    /* Buttons */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }
    /* Modal */
    .modal-card {
        width: 95%;
        max-height: 90vh;
        margin: 0.5rem;
    }
    .modal-body {
        padding: 1rem;
    }
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .pagination a, .pagination span {
        min-width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    #contentWrapper {
        padding: 0.75rem !important;
    }
    .stat-card {
        padding: 0.75rem;
    }
    .stat-card h3 {
        font-size: 1.25rem;
    }
}

/* ============ Print ============ */
@media print {
    .sidebar, .top-navbar { display: none !important; }
    .main-content { width: 100% !important; }
}