/* =====================================================
   Toodoo - Styles CSS
   Application de gestion de tâches holistique
   ===================================================== */

/* Variables CSS */
:root {
    /* Couleurs principales */
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #7c8ff4;
    --accent: #764ba2;

    /* Couleurs des plans */
    --plan-pro: #3498db;
    --plan-futur: #9b59b6;
    --plan-perso: #27ae60;

    /* Couleurs de priorité */
    --priority-low: #95a5a6;
    --priority-normal: #3498db;
    --priority-high: #f39c12;
    --priority-urgent: #e74c3c;

    /* Couleurs de statut */
    --status-overdue: #e74c3c;
    --status-today: #f39c12;
    --status-upcoming: #27ae60;

    /* Couleurs neutres */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Espacements */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Bordures */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* Dimensions fixes */
    --header-height: 60px;
    --nav-height: 60px;
    --sidebar-width: 280px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Utilitaires */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* =====================================================
   Écrans (Login / App)
   ===================================================== */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Écran de connexion */
#login-screen {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    justify-content: center;
    align-items: center;
    padding: var(--space-md);
}

.login-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.login-logo h1 {
    font-size: 2rem;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
}

.login-logo p {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.login-form .form-group {
    margin-bottom: var(--space-md);
}

.login-form label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--space-xs);
}

.login-form input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color var(--transition-fast);
}

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

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
    font-size: 0.875rem;
}

/* =====================================================
   Boutons
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

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

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

.btn-accent:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

/* =====================================================
   Header
   ===================================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.plan-selector {
    display: flex;
    gap: var(--space-xs);
    background: var(--gray-100);
    padding: var(--space-xs);
    border-radius: var(--radius-lg);
}

.plan-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--gray-600);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.plan-btn:hover {
    background: var(--gray-200);
}

.plan-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.plan-btn[data-plan="1"].active { color: var(--plan-pro); }
.plan-btn[data-plan="2"].active { color: var(--plan-futur); }
.plan-btn[data-plan="3"].active { color: var(--plan-perso); }

/* =====================================================
   Main Content
   ===================================================== */
.app-main {
    flex: 1;
    margin-top: var(--header-height);
    margin-bottom: var(--nav-height);
    overflow: hidden;
}

.view {
    display: none;
    height: calc(100vh - var(--header-height) - var(--nav-height));
    overflow: auto;
}

.view.active {
    display: block;
}

/* =====================================================
   Navigation
   ===================================================== */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm);
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-btn i {
    font-size: 1.25rem;
}

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

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: var(--radius-full);
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--white);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    transition: left var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    z-index: 150;
    transition: all var(--transition-normal);
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-header h2 {
    font-size: 1.125rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.sidebar-section {
    margin-bottom: var(--space-lg);
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: var(--space-sm);
}

.plan-list,
.action-list {
    list-style: none;
}

.plan-list li,
.action-list li {
    margin-bottom: var(--space-xs);
}

.btn-sidebar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--gray-700);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-sidebar:hover {
    background: var(--gray-100);
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--gray-200);
}

/* =====================================================
   Mind Map
   ===================================================== */
.mindmap-toolbar {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    display: flex;
    gap: var(--space-xs);
    background: var(--white);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.mindmap-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(90deg, var(--gray-200) 1px, transparent 1px),
        linear-gradient(var(--gray-200) 1px, transparent 1px);
    background-size: 20px 20px;
}

.mindmap-svg {
    width: 100%;
    height: 100%;
}

/* Noeud Mind Map */
.mindmap-node {
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.mindmap-node:hover {
    transform: scale(1.05);
}

.mindmap-node-bg {
    fill: var(--white);
    stroke: var(--gray-300);
    stroke-width: 2;
    rx: 8;
}

.mindmap-node.task .mindmap-node-bg {
    stroke-dasharray: 5, 3;
}

.mindmap-node.completed .mindmap-node-bg {
    fill: var(--gray-100);
    opacity: 0.7;
}

.mindmap-node-text {
    font-size: 14px;
    fill: var(--gray-800);
    text-anchor: middle;
    dominant-baseline: middle;
}

.mindmap-node.completed .mindmap-node-text {
    text-decoration: line-through;
    fill: var(--gray-500);
}

.mindmap-link {
    fill: none;
    stroke: var(--gray-300);
    stroke-width: 2;
}

/* Couleurs par plan */
.mindmap-node[data-plan="1"] .mindmap-node-bg { stroke: var(--plan-pro); }
.mindmap-node[data-plan="2"] .mindmap-node-bg { stroke: var(--plan-futur); }
.mindmap-node[data-plan="3"] .mindmap-node-bg { stroke: var(--plan-perso); }

/* =====================================================
   To-Do List
   ===================================================== */
.todo-sections {
    padding: var(--space-md);
    max-width: 800px;
    margin: 0 auto;
}

.todo-section {
    margin-bottom: var(--space-lg);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
}

.todo-overdue .section-header h2 { color: var(--status-overdue); }
.todo-today .section-header h2 { color: var(--status-today); }
.todo-upcoming .section-header h2 { color: var(--status-upcoming); }

.task-count {
    background: var(--gray-200);
    color: var(--gray-600);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Carte de tâche */
.task-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--gray-300);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: all var(--transition-fast);
}

.task-card:hover {
    box-shadow: var(--shadow-md);
}

.task-card[data-plan="1"] { border-left-color: var(--plan-pro); }
.task-card[data-plan="2"] { border-left-color: var(--plan-futur); }
.task-card[data-plan="3"] { border-left-color: var(--plan-perso); }

.task-card.priority-haute { border-left-color: var(--priority-high); }
.task-card.priority-urgente { border-left-color: var(--priority-urgent); }

.task-checkbox {
    flex-shrink: 0;
}

.task-checkbox input {
    display: none;
}

.task-checkbox label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.task-checkbox label:hover {
    border-color: var(--primary);
    background: var(--gray-100);
}

.task-checkbox input:checked + label {
    background: var(--primary);
    border-color: var(--primary);
}

.task-checkbox input:checked + label::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--white);
    font-size: 0.75rem;
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-weight: 500;
    margin-bottom: var(--space-xs);
    word-break: break-word;
}

.task-card.completed .task-title {
    text-decoration: line-through;
    color: var(--gray-500);
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 0.75rem;
    color: var(--gray-500);
}

.task-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.task-actions {
    display: flex;
    gap: var(--space-xs);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.task-card:hover .task-actions {
    opacity: 1;
}

.task-actions button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.task-actions button:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.task-actions button.delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Animation de complétion */
.task-card.completing {
    animation: taskComplete 0.5s ease forwards;
}

@keyframes taskComplete {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    50% {
        opacity: 0.5;
        transform: translateX(10px);
    }
    100% {
        opacity: 0;
        transform: translateX(50px);
        height: 0;
        padding: 0;
        margin: 0;
    }
}

/* =====================================================
   Calendrier
   ===================================================== */
.calendar-container {
    height: 100%;
    padding: var(--space-md);
}

/* Styles FullCalendar personnalisés */
.fc {
    --fc-border-color: var(--gray-200);
    --fc-button-bg-color: var(--primary);
    --fc-button-border-color: var(--primary);
    --fc-button-hover-bg-color: var(--primary-dark);
    --fc-button-hover-border-color: var(--primary-dark);
    --fc-button-active-bg-color: var(--primary-dark);
    --fc-today-bg-color: rgba(102, 126, 234, 0.1);
}

.fc .fc-toolbar-title {
    font-size: 1.125rem;
}

.fc .fc-button {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.875rem;
}

.fc-event {
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    font-size: 0.75rem;
}

.fc-event[data-plan="1"] {
    background: var(--plan-pro);
    border-color: var(--plan-pro);
}

.fc-event[data-plan="2"] {
    background: var(--plan-futur);
    border-color: var(--plan-futur);
}

.fc-event[data-plan="3"] {
    background: var(--plan-perso);
    border-color: var(--plan-perso);
}

/* =====================================================
   Journal
   ===================================================== */
.journal-header {
    padding: var(--space-md);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.journal-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.125rem;
    margin-bottom: var(--space-md);
}

.journal-stats {
    display: flex;
    gap: var(--space-lg);
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.journal-list {
    padding: var(--space-md);
    max-width: 800px;
    margin: 0 auto;
}

.journal-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--gray-200);
}

.journal-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ecfdf5;
    color: #10b981;
    border-radius: var(--radius-full);
}

.journal-content {
    flex: 1;
}

.journal-title {
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.journal-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    display: flex;
    gap: var(--space-md);
}

/* =====================================================
   Modals
   ===================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: var(--space-md);
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.125rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-top: 1px solid var(--gray-200);
}

/* Formulaires */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
}

/* =====================================================
   Toasts
   ===================================================== */
.toast-container {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--space-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--gray-800);
    color: var(--white);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

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

/* =====================================================
   Responsive - Desktop
   ===================================================== */
@media (min-width: 768px) {
    .hide-mobile {
        display: inline;
    }

    .plan-btn span {
        display: inline;
    }

    .nav-btn {
        flex-direction: row;
        font-size: 0.875rem;
    }

    .nav-btn i {
        font-size: 1rem;
    }

    .task-actions {
        opacity: 1;
    }
}

@media (min-width: 1024px) {
    :root {
        --nav-height: 0px;
    }

    .app-nav {
        position: static;
        height: auto;
        border-top: none;
        border-bottom: 1px solid var(--gray-200);
        justify-content: flex-start;
        gap: var(--space-md);
        padding: 0 var(--space-md);
        background: var(--gray-50);
    }

    .app-main {
        margin-bottom: 0;
    }

    .view {
        height: calc(100vh - var(--header-height) - 48px);
    }

    .nav-btn {
        padding: var(--space-md);
        position: relative;
    }

    .nav-btn.active::after {
        bottom: 0;
        width: 100%;
        height: 3px;
        border-radius: 0;
    }

    .toast-container {
        bottom: var(--space-md);
    }
}

/* =====================================================
   Responsive - Mobile small
   ===================================================== */
@media (max-width: 480px) {
    .plan-selector {
        overflow-x: auto;
        max-width: 100%;
    }

    .plan-btn span {
        display: none;
    }

    .header-right .btn span {
        display: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .journal-stats {
        justify-content: space-between;
    }
}
