:root {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: width 0.3s ease;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 3rem;
}

.logo-area i {
    font-size: 1.5rem;
    color: var(--primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-item.active {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-item i {
    font-size: 1.25rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-info .role {
    font-size: 0.75rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-bar {
    height: 80px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.top-bar h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background-color: var(--bg-body);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

.stat-card .trend {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend.positive {
    color: var(--success);
}

.trend.negative {
    color: var(--danger);
}

.charts-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    min-height: 300px;
}

.chart-card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Sales Table */
.table-container {
    background: var(--bg-surface);
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sales-table {
    width: 100%;
    border-collapse: collapse;
}

.sales-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sales-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sales-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-pagada {
    background-color: #dcfce7;
    color: #166534;
}

.status-pendiente {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: transform 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Utilities */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background-color: var(--bg-body);
    color: var(--primary);
}

.btn-delete:hover {
    color: var(--danger);
    background-color: #fee2e2;
}

/* Provider Cards Grid */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card.provider-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.card.provider-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.card-header {
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.provider-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.provider-info {
    flex: 1;
    overflow: hidden;
}

.provider-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-actions {
    display: flex;
    gap: 0.25rem;
}

.card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.data-row i {
    color: var(--primary);
    width: 16px;
    text-align: center;
}

.badge-category {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

/* Responsive Sidebar (Mobile/Tablet/Compact) */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 1.5rem 0.5rem;
    }

    .sidebar .logo-area {
        justify-content: center;
    }

    .sidebar .logo-area span {
        display: none;
    }

    .sidebar .logo-area i {
        font-size: 2rem;
        margin: 0;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: 0.75rem;
    }

    .sidebar .nav-item span {
        display: none;
    }

    .sidebar .nav-item i {
        font-size: 1.5rem;
    }

    .sidebar .user-profile {
        padding: 1rem 0.5rem;
        justify-content: center;
    }

    .sidebar .user-info {
        display: none;
    }

    .sidebar .avatar {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }

    /* Adjust logout button if present inside sidebar footer */
    .sidebar .user-profile button {
        display: none;
    }
}

/* Mobile Responsive (Phones < 768px) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    /* Transform Sidebar to Bottom Nav */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        flex-direction: row;
        padding: 0.5rem;
        z-index: 50;
        background-color: var(--bg-sidebar);
        justify-content: space-around;
        align-items: center;
        border-top: 1px solid rgba(255,255,255,0.1);
        box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.1);
    }
    
    .sidebar .logo-area, .sidebar .user-profile {
        display: none; 
    }

    .nav-menu {
        flex-direction: row;
        justify-content: space-evenly;
        width: 100%;
        gap: 0;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 0.5rem;
        font-size: 0.7rem;
        justify-content: center;
        text-align: center;
        border-radius: 8px;
    }
    
    .nav-item:hover {
        background-color: transparent; /* Remove hover bg on touch */
    }

    .nav-item.active {
        background-color: transparent;
        color: var(--primary);
    }

    .nav-item i {
        font-size: 1.5rem;
        margin: 0;
    }

    .sidebar .nav-item span {
        display: block; /* Restore text for bottom nav */
        font-size: 0.6rem;
        font-weight: 500;
    }

    /* Main Content Adjustments */
    .main-content {
        height: 100%; 
        overflow: auto;
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .content-area {
        padding: 1rem;
        overflow-y: visible; /* Let main-content handle scroll */
    }
    
    .top-bar {
        padding: 0 1rem; 
        height: 60px;
    }
    
    .top-bar h1 {
        font-size: 1.1rem;
    }

    /* Grid Stacking */
    .dashboard-grid {
        grid-template-columns: 1fr; 
        gap: 1rem;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
    
    /* Tables Scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sales-table {
        min-width: 600px; /* Force scroll */
    }
    
    .sales-table th, .sales-table td {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    /* Modal Full Width */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 1rem;
        margin: 0.5rem;
        max-height: 85vh;
    }
    
    .modal-header {
        margin-bottom: 1rem;
    }
    
    /* Toolbar Stacking */
    .actions-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .actions-toolbar > div {
        flex-direction: column;
        align-items: stretch;
    }
    
    .actions-toolbar button, .actions-toolbar select, .actions-toolbar input {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 0.5rem;
    }

    /* Adjust Date Filters container I added */
    .actions-toolbar div[style*="display:flex"] {
        flex-wrap: wrap;
    }
    
    .grid-view {
        grid-template-columns: 1fr;
    }
}