/* Variables CSS */
:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --background-color: #f5f6fa;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #ecf0f1;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --nav-height: 70px;
    --header-height: 100px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: var(--nav-height);
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 15px 20px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.month-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.month-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#current-month {
    font-size: 1.1rem;
    font-weight: 500;
    min-width: 150px;
    text-align: center;
}

/* Navigation mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--card-background);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 12px 16px;
    min-width: 60px;
    min-height: 50px;
    transition: color 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nav-btn.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 1.3rem;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Contenu principal */
.main-content {
    margin-top: var(--header-height);
    padding: 15px;
    padding-bottom: 80px;
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Cards */
.card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

/* Formulaires */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-color);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input[type="color"] {
    padding: 5px;
    height: 45px;
    cursor: pointer;
}

/* Boutons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

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

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

.btn-secondary:hover {
    background: #dfe6e9;
}

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

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

/* Total du mois */
.total-month {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Liste des dépenses */
.expenses-list {
    max-height: 400px;
    overflow-y: auto;
}

.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s;
}

.expense-item:last-child {
    border-bottom: none;
}

.expense-item:hover {
    background: var(--background-color);
}

.expense-info {
    flex: 1;
}

.expense-category {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
    display: inline-block;
    margin-bottom: 4px;
}

.expense-description {
    font-size: 0.9rem;
    color: var(--text-color);
}

.expense-date {
    font-size: 0.75rem;
    color: var(--text-light);
}

.expense-amount {
    font-weight: 600;
    font-size: 1rem;
    color: var(--danger-color);
    margin-right: 10px;
}

.expense-actions {
    display: flex;
    gap: 5px;
}

.expense-edit {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.expense-edit:hover {
    opacity: 1;
}

.expense-delete {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.expense-delete:hover {
    opacity: 1;
}

/* Liste des catégories */
.categories-list {
    max-height: 400px;
    overflow-y: auto;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s;
}

.category-item:last-child {
    border-bottom: none;
}

.category-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.category-name {
    font-weight: 500;
}

.category-budget {
    font-size: 0.85rem;
    color: var(--text-light);
}

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

.category-edit,
.category-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.category-edit:hover,
.category-delete:hover {
    opacity: 1;
}

.category-delete {
    color: var(--danger-color);
}

/* Statistiques */
.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: var(--background-color);
    border-radius: 8px;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

.stat-value.positive {
    color: var(--secondary-color);
}

.stat-value.negative {
    color: var(--danger-color);
}

/* Graphiques */
#chart-container,
#chart-evolution-container {
    position: relative;
    height: 250px;
    margin: 10px 0;
}

/* Détails par catégorie */
.stats-details {
    max-height: 300px;
    overflow-y: auto;
}

.stats-category-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.stats-category-item:last-child {
    border-bottom: none;
}

.stats-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stats-category-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.stats-category-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.stats-category-amount {
    font-weight: 600;
}

.stats-progress {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.stats-progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.stats-budget-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* Configuration */
.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-text {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    border-radius: 12px;
    padding: 25px;
    max-width: 350px;
    width: 100%;
    box-shadow: var(--shadow);
}

.modal-content h3 {
    margin-bottom: 15px;
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-light);
}

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

.modal-actions .btn {
    flex: 1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
    max-width: 300px;
    text-align: center;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast.success {
    background: var(--secondary-color);
}

.toast.error {
    background: var(--danger-color);
}

/* États vides */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.empty-state-text {
    font-size: 0.9rem;
}

/* Responsive - Tablette et desktop */
@media (min-width: 768px) {
    .main-content {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .stats-summary {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }
}

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

.card {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
