/* =====================================================
   COOPFUNA LTDA - Estilos con Sidebar
   ===================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    --primary-color: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #818cf8;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --light-color: #f8f9fa;
    --dark-color: #1f2937;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #334155;
    --sidebar-active: #4f46e5;
}

/* =====================================================
   Base Styles
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f1f5f9;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--primary-light);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-toggle:hover {
    color: white;
}

#sidebarClose {
    display: none;
}

/* User Info */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    margin-top: 0.25rem;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-section {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item .nav-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item .nav-link.active {
    background: rgba(79, 70, 229, 0.2);
    color: var(--primary-light);
    border-left-color: var(--primary-color);
}

.nav-item .nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-item .nav-link span {
    flex: 1;
}

/* Submenu */
.submenu-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.has-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.2);
}

.has-submenu.open .submenu {
    display: block;
}

.submenu li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem 0.6rem 3rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.submenu li a:hover {
    color: white;
    background: var(--sidebar-hover);
}

.submenu li a i {
    font-size: 0.9rem;
}

/* Sidebar Footer */
.sidebar-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
}

.footer-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.footer-link.text-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

/* =====================================================
   Main Wrapper
   ===================================================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* =====================================================
   Topbar
   ===================================================== */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar .sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.topbar .sidebar-toggle:hover {
    background-color: var(--light-color);
}

.topbar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--dark-color);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-date {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

/* =====================================================
   Main Content
   ===================================================== */
.main-content {
    flex: 1;
    padding: 0;
}

.main-content .container-fluid {
    max-width: 1600px;
}

/* =====================================================
   Main Footer
   ===================================================== */
.main-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: white;
    border-top: 1px solid #e2e8f0;
    font-size: 0.8rem;
    color: var(--secondary-color);
}

/* =====================================================
   Login Page (No Sidebar)
   ===================================================== */
.main-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* =====================================================
   Cards
   ===================================================== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* =====================================================
   Dashboard Stats
   ===================================================== */
.stat-card {
    padding: 1.5rem;
    border-radius: 12px;
    color: white;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.3;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-card .stat-label {
    opacity: 0.9;
    font-size: 0.875rem;
}

.stat-card.bg-primary-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card.bg-success-gradient {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.stat-card.bg-warning-gradient {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card.bg-info-gradient {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* =====================================================
   Forms
   ===================================================== */
.form-control, .form-select {
    border-radius: 8px;
    padding: 0.65rem 1rem;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.4rem;
    font-size: 0.875rem;
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
    border-radius: 8px;
    padding: 0.55rem 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

/* =====================================================
   Tables
   ===================================================== */
.table {
    font-size: 0.9rem;
}

.table th {
    font-weight: 600;
    color: var(--dark-color);
    border-bottom-width: 1px;
    background: #f8fafc;
}

.table td {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* =====================================================
   Badges
   ===================================================== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 6px;
}

/* =====================================================
   Alerts
   ===================================================== */
.alert {
    border: none;
    border-radius: 10px;
    border-left: 4px solid;
}

.alert-success {
    background: #ecfdf5;
    border-left-color: var(--success-color);
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    border-left-color: var(--danger-color);
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border-left-color: var(--warning-color);
    color: #92400e;
}

.alert-info {
    background: #ecfeff;
    border-left-color: var(--info-color);
    color: #155e75;
}

/* =====================================================
   Scrollbar
   ===================================================== */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1001; /* Por encima del overlay */
        position: fixed !important;
        left: 0 !important;
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    #sidebarClose {
        display: block;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
    }
    
    .topbar .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* Overlay when sidebar is open */
    body.sidebar-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
        animation: fadeIn 0.3s ease;
    }
    
    body.sidebar-open {
        overflow: hidden;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 575.98px) {
    .topbar-date {
        display: none;
    }
    
    .main-content .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* =====================================================
   Utilities
   ===================================================== */
.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }

/* =====================================================
   Page Specific Overrides
   ===================================================== */
.login-card {
    max-width: 400px;
    width: 100%;
    margin: 2rem;
}

/* Print Styles */
@media print {
    .sidebar,
    .topbar,
    .main-footer {
        display: none !important;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
    }
    
    .main-content {
        padding: 0 !important;
    }
}
