/* ========================================
   RESET ET VARIABLES
   ======================================== */

:root {
    --primary: #4CAF50;
    --secondary: #2196F3;
    --danger: #f44336;
    --success: #8BC34A;
    --warning: #FF9800;
    --light: #f5f5f5;
    --dark: #333;
    --border: #ddd;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    
    /* Couleurs pastel pour les types */
    --event-color: #E3F2FD;
    --reminder-color: #FFF3E0;
    --task-color: #E8F5E9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    font-size: 15px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

/* ========================================
   HEADER
   ======================================== */

.header-bar {
    background: white;
    padding: 20px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
    flex-wrap: wrap;
}

.header-bar h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--dark);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
}

.logout-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
    text-decoration: none;
}

.logout-btn:hover {
    color: var(--danger);
}

/* ========================================
   ALERTS
   ======================================== */

.alert {
    padding: 15px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    animation: slideDown 0.3s ease-out;
    font-size: 0.95rem;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ========================================
   BOUTONS DE TYPE (dans header)
   ======================================== */

.type-buttons {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.type-btn {
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.type-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.type-btn-event {
    background: var(--event-color);
    border: 3px solid #1976D2;
    color: #1976D2;
}

.type-btn-event:hover {
    background: #BBDEFB;
}

.type-btn-reminder {
    background: var(--reminder-color);
    border: 3px solid #F57C00;
    color: #F57C00;
}

.type-btn-reminder:hover {
    background: #FFE0B2;
}

.type-btn-task {
    background: var(--task-color);
    border: 3px solid #388E3C;
    color: #388E3C;
}

.type-btn-task:hover {
    background: #C8E6C9;
}

/* ========================================
   FORMULAIRES
   ======================================== */

.form-container {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.form-container h2 {
    margin-bottom: 25px;
    color: var(--dark);
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
    font-size: 0.95rem;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="file"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin: 0;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-group-inline {
    display: flex;
    flex-direction: row;
    gap: 15px;
    flex-wrap: nowrap;
}

.checkbox-group-inline label {
    white-space: nowrap;
    font-size: 0.9rem;
}

.recurrence-group-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recurrence-option-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--light);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    flex-wrap: nowrap;
}

.recurrence-option-inline:hover {
    background: #e8e8e8;
}

.recurrence-option-inline input[type="radio"] {
    width: auto;
    cursor: pointer;
    flex-shrink: 0;
}

.recurrence-option-inline .interval-input {
    width: 50px;
    padding: 4px 8px;
    text-align: center;
    flex-shrink: 0;
}

.recurrence-option-inline span {
    white-space: nowrap;
    font-size: 0.9rem;
}

.recurrence-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recurrence-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--light);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.recurrence-option:hover {
    background: #e8e8e8;
}

.recurrence-option input[type="radio"] {
    width: auto;
    cursor: pointer;
}

.recurrence-option input[type="number"] {
    width: auto;
    padding: 5px 10px;
}

.subtask-input {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.subtask-input input {
    flex: 1;
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.btn-remove:hover {
    background: #d32f2f;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

/* ========================================
   BOUTONS
   ======================================== */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: #999;
    color: white;
}

.btn-secondary:hover {
    background: #777;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    margin-top: 10px;
}

.btn-icon {
    background: var(--success);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #7CB342;
}

.btn-icon.btn-danger {
    background: var(--danger);
}

.btn-icon.btn-danger:hover {
    background: #d32f2f;
}

.btn-icon-simple {
    background: none;
    border: none;
    color: var(--dark);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: transform 0.2s, opacity 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-icon-simple:hover {
    transform: scale(1.2);
    opacity: 0.7;
}

.btn-icon-inline {
    background: none;
    border: none;
    color: var(--dark);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s, opacity 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-icon-inline:hover {
    transform: scale(1.2);
    opacity: 0.7;
}

/* ========================================
   LISTING DES ITEMS
   ======================================== */

.items-section {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.items-section h2 {
    margin-bottom: 25px;
    color: var(--dark);
    font-size: 1.6rem;
}

.empty-message {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
    font-size: 1rem;
}

/* Carte item */
.item-card {
    background: white;
    border-radius: var(--radius);
    padding: 10px 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 5px solid #ddd;
    transition: all 0.3s;
    cursor: pointer;
}

.item-card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}

/* Couleurs selon le type */
.item-card.item-event {
    background: var(--event-color);
    border-left-color: #2196F3;
}

.item-card.item-reminder {
    background: var(--reminder-color);
    border-left-color: #FF9800;
}

.item-card.item-task {
    background: var(--task-color);
    border-left-color: #4CAF50;
}

.item-card.completed {
    opacity: 0.6;
    background: #f5f5f5 !important;
}

/* Item en retard */
.item-card.item-overdue {
    background: #ffebee !important;
    border-left-color: #f44336 !important;
}

.item-card.item-overdue:hover {
    background: #ffcdd2 !important;
}

/* En-tête collapsed (toujours visible) */
.item-header-collapsed {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 0;
}

/* Titre */
.item-title {
    font-size: 1.05rem;
    margin: 0;
    color: var(--dark);
    flex: 1;
    cursor: pointer;
    user-select: none;
    line-height: 1.4;
}

.item-subtitle {
    font-size: 0.8rem;
    color: #898989;
    font-weight: normal;
    margin: 0 0 0 0;
    line-height: 0.5;
}

.item-title:hover {
    opacity: 0.7;
}

.item-actions-inline {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Contenu étendu (caché par défaut) */
.item-content-expanded {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

/* Description */
.item-description {
    color: #555;
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Date/Heure */
.item-datetime {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

.recurrence-info {
    background: rgba(0,0,0,0.08);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

/* Fichiers */
.item-files {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.file-link {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(0,0,0,0.08);
    color: var(--dark);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.file-link:hover {
    background: rgba(0,0,0,0.15);
}

/* Sous-tâches */
.subtasks-list {
    background: rgba(255,255,255,0.5);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.subtask-item:hover {
    background: rgba(0,0,0,0.05);
    border-radius: 5px;
}

.subtask-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.subtask-item span {
    flex: 1;
    font-size: 0.95rem;
}

.completed-text {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Footer de la carte */
.item-footer {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.item-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-meta-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.item-author {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.item-status {
    font-size: 0.85rem;
    color: #666;
}

.item-notifications-sent {
    font-size: 0.85rem;
    color: #666;
    margin-top: 3px;
}

.item-notifications-sent span {
    cursor: help;
    margin-right: 3px;
}

.item-meta-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.item-type-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(0,0,0,0.1);
    white-space: nowrap;
}

.item-status-icons {
    display: flex;
    gap: 5px;
    font-size: 1rem;
}

.item-status-icons span {
    cursor: help;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }

    /* Header responsive */
    .header-bar {
        padding: 15px 20px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    
    .header-bar h1 {
        font-size: 1.4rem;
        flex: 1;
        min-width: 0;
    }
    
    .header-right {
        flex-shrink: 0;
        width: auto;
        justify-content: flex-end;
    }
    
    .profile-img {
        width: 38px;
        height: 38px;
    }
    
    /* Boutons de type sur une nouvelle ligne */
    .type-buttons {
        width: 100%;
        gap: 6px;
        order: 3;
        margin-top: 10px;
    }

    .type-btn {
        flex: 1;
        padding: 10px 6px;
        font-size: 0.8rem;
    }

    /* Formulaires */
    .form-container {
        padding: 20px;
    }

    .form-container h2 {
        font-size: 1.3rem;
    }

    .form-row {
        grid-template-columns: 2fr 1fr;
        gap: 10px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .checkbox-group-inline {
        justify-content: space-between;
        gap: 8px;
    }

    .checkbox-group-inline label {
        font-size: 0.85rem;
    }

    .recurrence-option-inline {
        padding: 8px;
        gap: 6px;
    }

    .recurrence-option-inline span {
        font-size: 0.85rem;
    }

    .recurrence-option-inline .interval-input {
        width: 45px;
        padding: 3px 6px;
    }

    /* Items section */
    .items-section {
        padding: 20px;
    }

    .items-section h2 {
        font-size: 1.3rem;
    }

    .item-card {
        padding: 10px;
    }

    .item-title {
        font-size: 0.95rem;
    }

    .item-subtitle {
    	font-size: 0.7rem;
    }

    /* Footer mobile - Garde la même structure */
    .item-footer {
        flex-direction: column;
        gap: 5px;
    }

    /* Actions inline plus petites */
    .btn-icon-inline {
        font-size: 0.95rem;
        padding: 3px;
    }

    .item-actions-inline {
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .header-bar h1 {
        font-size: 1.2rem;
    }

    .profile-img {
        width: 32px;
        height: 32px;
    }

    .logout-btn {
        font-size: 1.5rem;
    }

    .type-btn {
        font-size: 0.75rem;
        padding: 10px 8px;
    }

    .item-title {
        font-size: 0.9rem;
    }

    .item-subtitle {
    font-size: 0.7rem;
    }

    .btn-icon-inline {
        font-size: 0.85rem;
        padding: 2px;
    }

    .item-actions-inline {
        gap: 3px;
    }
}

/* Rendre le titre cliquable sur mobile */
.header-bar h1 {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
}

.header-bar h1:active {
    transform: scale(0.98);
}

/* Titre cliquable */
.header-bar h1 {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.header-bar h1:active {
    opacity: 0.7;
}

/* Icône de sauvegarde cliquable */
#backup-icon {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    display: inline-block;
    padding: 5px;
    margin: -5px;
}

#backup-icon:active {
    transform: scale(1.2);
    opacity: 0.7;
}