/* ========================================
   Variables y Reset
   ======================================== */
:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    
    --income-color: #48bb78;
    --expense-color: #f56565;
    --balance-color: #667eea;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Container
   ======================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ========================================
   Notificaciones
   ======================================== */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.notification {
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--info-color);
}

.notification.success {
    border-left-color: var(--success-color);
}

.notification.error {
    border-left-color: var(--danger-color);
}

.notification.warning {
    border-left-color: var(--warning-color);
}

.notification i {
    font-size: 20px;
}

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

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

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

.notification.info i {
    color: var(--info-color);
}

.notification-content {
    flex: 1;
}

.notification-content p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

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

/* ========================================
   Header
   ======================================== */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
}

.logo i {
    font-size: 28px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ========================================
   Tabs Navigation
   ======================================== */
.tabs-navigation {
    background: white;
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: none;
    border: none;
    padding: 16px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn i {
    font-size: 16px;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    padding: 30px 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* ========================================
   Sections
   ======================================== */
section {
    margin-bottom: 40px;
}

.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-left: 40px;
}

/* ========================================
   Upload Area
   ======================================== */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    background: white;
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.02);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.upload-area i {
    font-size: 64px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-area h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.upload-area p {
    color: var(--text-secondary);
    margin: 10px 0;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 15px;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

.btn i {
    font-size: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

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

.btn-danger:hover {
    background: #e53e3e;
}

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

.btn-success:hover {
    background: #38a169;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Summary Cards
   ======================================== */
.summary-cards, .summary-section, .income-summary, .expenses-summary, .month-summary, .rules-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.summary-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.summary-card.balance .card-icon {
    background: linear-gradient(135deg, var(--balance-color) 0%, var(--secondary-color) 100%);
}

.summary-card.income .card-icon {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.summary-card.expense .card-icon {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.summary-card.transactions .card-icon {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
}

.summary-card:not(.balance):not(.income):not(.expense):not(.transactions) .card-icon {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.card-content {
    flex: 1;
}

.card-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ========================================
   Charts
   ======================================== */
.charts-section {
    margin-bottom: 30px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.chart-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-container {
    position: relative;
}

/* ========================================
   Month Selector
   ======================================== */
.month-selector-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.selector-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.form-select {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.form-select:hover {
    border-color: var(--primary-color);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ========================================
   Rules Section
   ======================================== */
.rules-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.info-card {
    background: #ebf8ff;
    border: 2px solid #bee3f8;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
}

.info-card h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--info-color);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card ul {
    list-style: none;
    padding: 0;
}

.info-card li {
    padding: 8px 0;
    color: var(--text-primary);
    line-height: 1.6;
}

.info-card li strong {
    color: var(--info-color);
}

/* ========================================
   Filters
   ======================================== */
.filters-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.filters-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

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

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: var(--transition);
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-info {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========================================
   Tables
   ======================================== */
.table-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.table-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-responsive {
    overflow-x: auto;
}

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

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: var(--border-color);
}

.data-table th i {
    margin-left: 4px;
    font-size: 12px;
}

.data-table td {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.02);
}

.data-table .empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px !important;
}

/* ========================================
   Transaction Types
   ======================================== */
.amount-income {
    color: var(--income-color);
    font-weight: 600;
}

.amount-expense {
    color: var(--expense-color);
    font-weight: 600;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.category-badge:hover {
    background: var(--border-color);
}

.category-badge i {
    font-size: 14px;
}

/* ========================================
   Category Editor (Inline)
   ======================================== */
.category-editor {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.editor-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.editor-content h4 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.editor-description {
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.editor-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.editor-category-btn {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.editor-category-btn:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.editor-category-btn i {
    font-size: 16px;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ========================================
   Action Buttons in Tables
   ======================================== */
.action-btn {
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 14px;
}

.action-btn:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.action-btn.delete:hover {
    color: var(--danger-color);
}

/* ========================================
   Footer
   ======================================== */
.footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
    margin-top: auto;
}

.footer p {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .tab-btn span {
        display: none;
    }
    
    .tab-btn {
        padding: 16px;
        justify-content: center;
    }
    
    .summary-cards, .income-summary, .expenses-summary, .month-summary, .rules-summary {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-row {
        flex-direction: column;
    }
    
    .search-box {
        width: 100%;
    }
    
    .btn-text {
        display: none;
    }
    
    .section-header h2 {
        font-size: 22px;
    }
    
    .section-header p {
        margin-left: 0;
        font-size: 14px;
    }
    
    .upload-area {
        padding: 40px 20px;
    }
    
    .editor-categories {
        grid-template-columns: 1fr;
    }
    
    .selector-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    
    .main-content {
        padding: 20px 0;
    }
    
    .chart-card, .table-card, .filters-card {
        padding: 16px;
    }
    
    .summary-card {
        padding: 16px;
    }
    
    .card-value {
        font-size: 24px;
    }
}

/* ========================================
   Utilities
   ======================================== */
.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 16px;
}

.mb-2 {
    margin-bottom: 16px;
}

.hidden {
    display: none !important;
}

/* ========================================
   Loading Spinner
   ======================================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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