/**
 * HABITS CSS - MODERNES DESIGN
 * Optimiert für Desktop & Mobile
 */

/* ==================== VARIABLES ==================== */
/*
 * Importieren der zentralen Variablen und Mappen der habits-spezifischen
 * Variablennamen auf die globale Farbpalette. Dadurch nutzen Habits
 * dieselben Farbtöne und Abstände wie der Rest der Anwendung.
 */
@import url('variables.css');

:root {
    /* Farbtöne für Habits */
    --habit-primary: var(--color-primary);
    --habit-success: var(--color-success);
    --habit-warning: var(--color-accent);
    --habit-danger: var(--color-error);
    --habit-info: var(--color-accent);

    /* Hintergrundfarben */
    --bg-primary: var(--color-surface);
    --bg-secondary: var(--color-background);
    --bg-card: var(--color-surface);

    /* Textfarben */
    --text-primary: var(--color-text-primary);
    --text-secondary: var(--color-text-secondary);
    --text-muted: var(--color-text-secondary);

    /* Rahmen und Schatten */
    --border-color: var(--color-border);
    --shadow-sm: var(--shadow-sm);
    --shadow-md: var(--shadow-md);
    --shadow-lg: var(--shadow-lg);

    /* Radien */
    --radius-sm: var(--radius-sm);
    --radius-md: var(--radius-md);
    --radius-lg: var(--radius-lg);

    /* Übergänge */
    --transition: all var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== CONTAINER ==================== */
.habits-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ==================== HEADER ==================== */
.habits-header {
    text-align: center;
    margin-bottom: 3rem;
}

.habits-hero h1 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.habits-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* ==================== STATS GRID ==================== */
.habits-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--habit-primary);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.stat-primary .stat-number {
    color: var(--habit-primary);
}

.stat-success .stat-number {
    color: var(--habit-success);
}

.stat-info .stat-number {
    color: var(--habit-info);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ==================== CREATE BUTTON ==================== */
.habits-actions {
    margin: 2rem 0;
}

.btn-create-habit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    /* Verwenden des einheitlichen Button‑Stils: primäre Farbe, runde Ecken und Schatten */
    background: var(--habit-primary);
    color: var(--color-surface);
    padding: 1rem 2.5rem;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn-create-habit:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-create-habit .btn-icon {
    font-size: 1.5rem;
    line-height: 1;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    font-weight: 500;
}

.alert-success {
    /* Einheitliche Erfolgsmeldungen: sanftes Grün aus der globalen Palette */
    background: rgba(102, 187, 106, 0.15);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.alert-error {
    /* Einheitliche Fehlermeldungen: sanftes Rot aus der globalen Palette */
    background: rgba(229, 115, 115, 0.15);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

/* ==================== HABITS GRID ==================== */
.habits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* ==================== HABIT CARD ==================== */
.habit-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
    display: flex;
    gap: 1.5rem;
    transition: var(--transition);
}

.habit-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.habit-card.completed {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-color: var(--habit-primary);
}

/* Left Border */
.habit-border {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* Icon */
.habit-icon {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Content */
.habit-content {
    flex: 1;
    min-width: 0;
}

.habit-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.habit-description {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Stats */
.habit-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
}

.habit-stat {
    color: var(--text-secondary);
}

.habit-stat strong {
    color: var(--text-primary);
    font-weight: 700;
}

.habit-stat-divider {
    color: var(--text-muted);
}

/* Meta */
.habit-meta {
    margin-bottom: 1rem;
}

.habit-rhythm {
    display: inline-block;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
}

/* Streak Badge */
.habit-streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: linear-gradient(135deg, #FF5722 0%, #F4511E 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(255, 87, 34, 0.3);
    margin-top: 0.75rem;
}

/* Actions */
.habit-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
}

/* Check Button */
.btn-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Verwendung der konsistenten Primärfarbe und weißem Text */
    background: var(--habit-primary);
    color: var(--color-surface);
    border: none;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-check:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.btn-check:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-check.btn-checked {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    cursor: default;
}

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

.check-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.check-icon.spinning {
    animation: spin 1s linear infinite;
}

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

/* Quick Actions */
.habit-quick-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-action {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-icon-action:hover {
    background: var(--bg-primary);
    border-color: var(--text-secondary);
    transform: scale(1.1);
}

/* ==================== EMPTY STATE ==================== */
.habits-empty {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.habits-empty h2 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.habits-empty p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}


/* ==================== MODALS ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    text-align: center;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.modal-content h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-warning {
    background: #fff3cd;
    color: #856404;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #ffeaa7;
}

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #FF5722 0%, #F4511E 100%);
    color: white;
    border-radius: var(--radius-lg);
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(255, 87, 34, 0.3);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

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

.btn-large {
    padding: 1.125rem 2.5rem;
    font-size: 1.125rem;
}

/* ==================== KONFETTI ==================== */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: confetti-fall 3s ease-in-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .habits-container {
        padding: 1.5rem 1rem;
    }
    
    .habits-hero h1 {
        font-size: 2rem;
    }
    
    .habits-subtitle {
        font-size: 1rem;
    }
    
    .habits-stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .habits-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .habit-card {
        flex-direction: column;
        padding: 1.5rem;
    }
    
    .habit-icon {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }
    
    .habit-actions {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
    }
    
    .btn-check {
        flex: 1;
    }
    
    .modal-content {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .habit-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .habit-stat-divider {
        display: none;
    }
    
    .btn-create-habit {
        width: 100%;
        justify-content: center;
    }
}
