/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.category-filter select,
.date-filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    height: 36px;
    box-sizing: border-box;
}

.transaction-edit-select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    height: 28px;
    box-sizing: border-box;
    min-width: 120px;
}

.date-filters {
    display: flex;
    gap: 10px;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.nav-buttons a,
.nav-buttons button {
    padding: 8px 16px;
    border: 2px solid #007bff;
    border-radius: 6px;
    background-color: white;
    color: #007bff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.nav-buttons a:hover,
.nav-buttons button:hover {
    background-color: #007bff;
    color: white;
}

.nav-buttons a.active,
.nav-buttons button.active {
    background-color: #007bff;
    color: white;
}

/* Message */
.message {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.message.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.message button {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    color: inherit;
}

/* Controls grid */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
}

.control-group input,
.control-group select,
.control-group button {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.control-group button {
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.control-group button:hover:not(:disabled) {
    background-color: #0056b3;
}

.control-group button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Statistics */
.stats {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    font-size: 14px;
}

.stats div {
    margin-bottom: 5px;
}

/* Add category form */
.add-category {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.add-category h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.add-category form {
    display: grid;
    /* grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); */
    gap: 15px;
    align-items: end;
}

.add-category .form-group {
    display: flex;
    flex-direction: column;
}

.add-category .form-group label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #555;
}

.add-category .form-group input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.add-category .form-group input[type="color"] {
    padding: 5px;
    height: 40px;
}

.add-category button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    height: fit-content;
}

.add-category button:hover:not(:disabled) {
    background-color: #218838;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cancel-btn {
    background-color: #6c757d !important;
}

.cancel-btn:hover:not(:disabled) {
    background-color: #545b62 !important;
}

/* Categories list */
.categories {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.categories h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.category-card {
    padding: 15px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #f8f9fa;
}

.category-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.category-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 10px;
}

.category-name {
    font-weight: 600;
    color: #2c3e50;
    flex-grow: 1;
}

.category-actions {
    display: flex;
    gap: 8px;
}

.edit-btn, .delete-btn {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.edit-btn {
    background-color: #007bff;
    color: white;
}

.edit-btn:hover:not(:disabled) {
    background-color: #0056b3;
}

.delete-btn {
    background-color: #dc3545;
    color: white;
}

.delete-btn:hover:not(:disabled) {
    background-color: #c82333;
}

.edit-btn:disabled, .delete-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.category-pattern {
    font-size: 12px;
    color: #6c757d;
    font-family: monospace;
}

/* Transactions table */
.transactions {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.transactions-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.edit-mode-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
}

.edit-mode-btn:hover {
    background: #f8f9fa;
}

.edit-mode-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.transactions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.transactions-table th,
.transactions-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.transactions-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.transactions-table tr:hover {
    background-color: rgba(248, 249, 250, 0.8);
}

.transactions-table tr.category-colored {
    background-color: rgba(255, 255, 255, 0.1);
}

.transactions-table tr.category-colored:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.transactions-table .amount {
    text-align: right;
    font-weight: 500;
}

.transactions-table .amount.positive {
    color: #28a745;
}

.transactions-table .amount.negative {
    color: #dc3545;
}

.transactions-table .balance {
    text-align: right;
}

.category-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.category-badge.categorized {
    background-color: #e3f2fd;
    color: #1976d2;
}

.category-badge.uncategorized {
    background-color: #f5f5f5;
    color: #666;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 16px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 16px;
}

/* Analytics */
.analytics {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.analytics h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.analytics-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.analytics-view-selector {
    display: flex;
    gap: 10px;
}

.analytics-view-selector button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
}

.analytics-view-selector button:hover {
    background: #f8f9fa;
}

.analytics-view-selector button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.analytics-filters {
    display: flex;
    gap: 10px;
}

.analytics-filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    height: 36px;
    box-sizing: border-box;
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .controls {
        grid-template-columns: 1fr;
    }
    
    .add-category form {
        grid-template-columns: 1fr;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .transactions-table {
        font-size: 14px;
    }
    
    .transactions-table th,
    .transactions-table td {
        padding: 8px;
    }
}

/* Transactions total */
.transactions-total {
    margin-top: 15px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    text-align: right;
    font-size: 16px;
    border-top: 2px solid #dee2e6;
}

.transactions-total strong {
    color: #2c3e50;
}

/* Summary page */
.summary {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.summary h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.summary-card {
    background: white;
    border: 2px solid var(--category-color, #ddd);
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.summary-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.summary-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 12px;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.summary-name {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.summary-stats {
    text-align: center;
}

.summary-total {
    margin-bottom: 8px;
}

.summary-total .amount {
    font-size: 24px;
    font-weight: 700;
}

.summary-count {
    color: #6c757d;
    font-size: 14px;
}

/* Login page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f5f5f5;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    color: #2c3e50;
    margin-bottom: 30px;
    text-align: center;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.login-field input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.login-card button {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.login-card button:hover:not(:disabled) {
    background-color: #0056b3;
}

.login-card button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.login-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.logout-btn {
    padding: 8px 16px;
    border: 2px solid #dc3545;
    border-radius: 6px;
    background-color: white;
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
}

.logout-btn:hover {
    background-color: #dc3545;
    color: white;
}

.loading-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #6c757d;
    font-size: 18px;
}