/* Forge - Modern Custom Styles */
/* Theme: Dark mode with orange/fire accents (forge/metal style) */

:root {
    /* Backgrounds */
    --bg-primary: #0D0D0F;
    --bg-card: #1A1A1E;
    --bg-hover: #252529;

    /* Accents - Orange/Fire theme */
    --accent-primary: #F97316;
    --accent-secondary: #FBBF24;
    --accent-success: #FB923C;
    --accent-primary-light: rgba(249, 115, 22, 0.15);

    /* Legacy aliases for compatibility */
    --habit-done: #F97316;
    --habit-done-light: rgba(249, 115, 22, 0.15);
    --habit-pending: #6B7280;
    --habit-skipped: #9CA3AF;
    --streak-color: #F97316;

    /* Text */
    --text-primary: #F5F5F5;
    --text-secondary: #9CA3AF;
    --text-disabled: #6B7280;

    /* Borders */
    --border-subtle: #27272A;
    --border-active: #F97316;

    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;

    /* Shadows */
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --glow-orange: 0 0 20px rgba(249, 115, 22, 0.3);

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

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Better text rendering + dark background */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg-primary) !important;
    color: var(--text-primary);
}

/* Navigation - Override Pico CSS */
nav.container {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    height: 56px !important;
    padding: 0 1.25rem !important;
    margin-top: 0 !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 9000;
    background: rgba(13, 13, 15, 0.97) !important;
}

/* Logo section - left */
nav.container > ul:first-child {
    display: flex !important;
    align-items: center !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    height: 56px !important;
}

nav.container > ul:first-child > li {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

nav.container > ul:first-child > li > a,
nav.container > ul:first-child > li > a strong {
    display: flex !important;
    align-items: center !important;
    color: var(--habit-done) !important;
    font-weight: 700 !important;
    font-size: 1.1rem !important;
    padding: 0 !important;
    background: none !important;
    text-decoration: none !important;
    letter-spacing: -0.02em !important;
}

nav.container > ul:first-child > li > a:hover {
    background: none !important;
    opacity: 0.85 !important;
}

/* Navigation links - center */
nav.container > ul:nth-child(2) {
    display: flex !important;
    flex-direction: row !important;
    gap: 2px !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 4px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border-radius: 8px !important;
    align-items: center !important;
    position: relative;
    height: 36px !important;
}

nav.container > ul:nth-child(2) > li {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 100% !important;
}

/* Separateur entre les liens */
nav.container > ul:nth-child(2) > li:not(:last-child)::after {
    content: '';
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.15);
    margin-left: 2px;
}

nav.container > ul:nth-child(2) > li > a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 10px !important;
    height: 28px !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    color: rgba(255, 255, 255, 0.6) !important;
    font-weight: 500 !important;
    font-size: 0.8rem !important;
    line-height: 1 !important;
    transition: all 0.15s ease !important;
    position: relative;
    z-index: 2;
    white-space: nowrap !important;
}

nav.container > ul:nth-child(2) > li > a:hover {
    color: white !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

nav.container > ul:nth-child(2) > li > a.active {
    font-weight: 600 !important;
    color: white !important;
    background: var(--accent-primary) !important;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35) !important;
}

nav.container > ul:nth-child(2) > li > a.active:hover {
    background: var(--habit-done) !important;
}

/* Sliding pill */
.nav-pill {
    position: absolute;
    background: var(--accent-primary);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
}

/* User menu in nav - right */
nav.container > .user-menu {
    display: flex !important;
    align-items: center !important;
    height: 56px !important;
    flex-shrink: 0 !important;
}

/* Date navigation */
.date-nav {
    display: flex;
    gap: 0.5rem;
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
}

.date-nav a {
    padding: 0.6rem 1.25rem;
    border-radius: 10px !important;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    color: var(--muted-color) !important;
    transition: all var(--transition-fast);
}

.date-nav a:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    transform: translateY(-1px);
}

.date-nav a:not(.outline) {
    background: var(--habit-done) !important;
    border-color: var(--habit-done) !important;
    color: white !important;
}

.date-nav a:not(.outline):hover {
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

/* Habits list */
.habits-list {
    margin-top: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Separator between pending and completed habits */
.habits-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.75rem 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.habits-separator::before,
.habits-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.habits-separator span {
    opacity: 0.7;
}

/* Completed habits - slightly dimmed */
.habit-row.completed {
    opacity: 0.7;
}

.habit-row.completed:hover {
    opacity: 1;
}

.habit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0;
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

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

.habit-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    font-size: 0.9rem;
}

.habit-info a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

.habit-info a:hover {
    color: var(--accent-primary);
}

/* Badges */
.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    background: var(--secondary);
    color: var(--secondary-inverse);
    white-space: nowrap;
}

.badge.streak {
    background: var(--streak-color);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.badge.streak::before {
    content: "🔥";
}

.badge.archived {
    background: var(--muted-color);
}

/* Check buttons */
.habit-form {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin: 0;
}

.check-btn {
    width: 2.25rem !important;
    height: 2.25rem !important;
    min-width: 2.25rem;
    max-width: 2.25rem;
    border-radius: 50% !important;
    font-size: 1.1rem;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.check-btn.done {
    background: var(--accent-primary) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.5);
}

.check-btn.pending {
    background: transparent !important;
    border: 2px solid var(--habit-pending) !important;
    color: var(--habit-pending) !important;
}

.check-btn:hover {
    transform: scale(1.08);
}

.check-btn:active {
    transform: scale(0.95);
}

.check-btn.done:hover {
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.6);
}

/* Measurable form */
.habit-form.measurable input[type="number"] {
    width: 5rem;
    text-align: center;
    margin: 0;
}

.target-info {
    color: var(--muted-color);
    font-size: 0.875rem;
}

.submit-btn {
    padding: 0.5rem 1rem;
    margin: 0;
}

/* Progress bar */
progress {
    width: 100%;
    height: 0.5rem;
    margin-bottom: var(--spacing-lg);
    border-radius: 9999px;
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background: var(--border-subtle);
    border-radius: 9999px;
}

progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: 9999px;
    transition: width 0.5s ease;
}

progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: 9999px;
}

/* Stats cards */
.stat-card {
    text-align: center;
    padding: var(--spacing-lg);
    border-radius: 12px;
    background: var(--bg-card);
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-color);
    margin-bottom: var(--spacing-sm);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--accent-primary);
}

/* Charts */
.chart-container {
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.chart-container h3 {
    margin-bottom: var(--spacing-md);
}

.heatmap, .score-chart, .weekly-bars {
    width: 100%;
    max-width: 100%;
    height: auto;
}

/* Habit management list */
.habits-manage-list {
    margin-top: var(--spacing-lg);
}

.habit-manage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
    gap: 0.4rem;
    background: var(--card-background-color);
    border-radius: var(--border-radius);
    transition: transform 0.15s, box-shadow 0.15s;
}

.habit-manage-row[draggable="true"] {
    cursor: grab;
}

.habit-manage-row[draggable="true"]:active {
    cursor: grabbing;
}

.habit-manage-row.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.drag-handle {
    color: var(--muted-color);
    padding: 0.25rem;
    margin-right: 0.5rem;
    cursor: grab;
    touch-action: none;
    display: flex;
    align-items: center;
}

.drag-handle:active {
    cursor: grabbing;
}

.habit-manage-row.archived .drag-handle {
    display: none;
}

.habit-manage-row.archived {
    opacity: 0.6;
}

.habit-manage-row .habit-info {
    flex-direction: column;
    align-items: flex-start;
}

.habit-manage-row small {
    color: var(--muted-color);
}

.habit-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.habit-actions a, .habit-actions button {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    margin: 0;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.page-header a[role="button"] {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Stats header */
.stats-header {
    padding-left: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.period-nav {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.period-nav a {
    padding: 0.5rem 1rem;
}

/* Form styling */
.form-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.days-grid label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.error-message {
    background: #f44336;
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--spacing-lg) * 2;
}

/* Dashboard */
.habit-summary-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.habit-summary-list li {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: none;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.habit-summary-list li:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(4px);
}

.habit-summary-list li:last-child {
    border-bottom: none;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.habit-summary-list a {
    text-decoration: none !important;
    color: inherit;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.habit-summary-list a:hover {
    color: var(--accent-primary);
}

.habit-summary-list .score {
    margin-left: auto;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-primary);
    background: var(--accent-primary-light);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
}

/* Actions */
.actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    justify-content: center;
}

/* Footer */
footer {
    margin-top: calc(var(--spacing-lg) * 2);
    padding: var(--spacing-lg);
    text-align: center;
    color: var(--muted-color);
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    nav.container {
        height: 52px !important;
        padding: 0 0.75rem !important;
    }

    nav.container > ul:first-child,
    nav.container > ul:first-child > li {
        height: 52px !important;
    }

    nav.container > ul:first-child > li > a,
    nav.container > ul:first-child > li > a strong {
        font-size: 1rem !important;
    }

    nav.container > ul:nth-child(2) {
        gap: 2px !important;
        padding: 3px !important;
        height: 32px !important;
    }

    nav.container > ul:nth-child(2) > li:not(:last-child)::after {
        height: 12px;
    }

    nav.container > ul:nth-child(2) > li > a {
        padding: 0 8px !important;
        height: 26px !important;
        font-size: 0.7rem !important;
    }

    nav.container > .user-menu {
        height: 52px !important;
    }

    .user-menu-btn {
        width: 32px;
        height: 32px;
    }

    .user-menu-btn svg {
        width: 16px;
        height: 16px;
    }

    .habit-row {
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-sm);
        padding: var(--spacing-md);
        border-radius: 10px;
    }

    .habit-row:hover {
        transform: none;
    }

    .habit-form {
        flex-shrink: 0;
    }

    .habit-manage-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .habit-actions {
        width: 100%;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-card h3 {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
    }

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

    .date-nav {
        justify-content: center;
        gap: 0.4rem;
    }

    .date-nav a {
        padding: 0.5rem 0.9rem;
        font-size: 0.8rem;
    }

    .page-header {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    main.container header h1 {
        font-size: 1.75rem;
    }

    main.container header p {
        font-size: 0.9rem;
    }
}

/* SVG chart styling */
svg text {
    font-family: inherit;
}

.heatmap rect {
    transition: opacity 0.2s;
}

.heatmap rect:hover {
    opacity: 0.8;
}

/* Dashboard - Trend card */
.trend-card {
    padding: var(--spacing-lg);
}

.trend-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.trend-icon {
    font-size: 2rem;
    font-weight: bold;
}

.trend-icon.up {
    color: var(--accent-primary);
}

.trend-icon.down {
    color: #f44336;
}

.trend-icon.stable {
    color: var(--muted-color);
}

.trend-text {
    color: var(--muted-color);
}

/* Dashboard - Week history */
.week-history {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) 0;
}

.day-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 0.25rem;
}

.day-bar-container {
    width: 100%;
    height: 80px;
    background: var(--border-subtle);
    border-radius: var(--border-radius);
    position: relative;
    display: flex;
    align-items: flex-end;
}

.day-bar {
    width: 100%;
    background: var(--accent-primary);
    border-radius: var(--border-radius);
    min-height: 2px;
    transition: height 0.3s ease;
}

.day-rate {
    font-size: 0.75rem;
    font-weight: bold;
}

.day-label {
    font-size: 0.75rem;
    color: var(--muted-color);
}

.day-date {
    font-size: 0.65rem;
    color: var(--muted-color);
}

/* Global heatmap */
.global-heatmap {
    width: 100%;
    max-width: 100%;
    height: auto;
}

.global-heatmap rect {
    transition: opacity 0.2s;
}

.global-heatmap rect:hover {
    opacity: 0.8;
}

/* Mobile adjustments for dashboard */
@media (max-width: 576px) {
    .week-history {
        gap: 2px;
    }

    .day-bar-container {
        height: 60px;
    }

    .day-rate {
        font-size: 0.65rem;
    }

    .trend-display {
        flex-direction: column;
        text-align: center;
    }
}

/* Mobile adjustments for habits */
@media (max-width: 576px) {
    .check-btn {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem !important;
        max-width: 2.5rem !important;
        font-size: 1.1rem;
    }

    .habit-row {
        padding: var(--spacing-sm);
    }

    .habit-info {
        font-size: 0.9rem;
    }

    .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }

    .habit-form.measurable input[type="number"] {
        width: 4rem;
        font-size: 0.9rem;
    }
}

/* User menu dropdown */
.user-menu {
    position: relative;
    z-index: 9999;
    display: flex;
    align-items: center;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.user-menu-btn svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.6);
    transition: color 0.15s ease;
}

.user-menu-btn:hover svg {
    color: white;
}

.user-dropdown {
    position: fixed;
    top: 60px;
    right: 1rem;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s ease;
    z-index: 99999;
    overflow: hidden;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.user-dropdown-header {
    padding: 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.user-dropdown-header small {
    color: var(--muted-color);
    font-size: 0.75rem;
}

.user-dropdown-header strong {
    display: block;
    color: white;
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

.user-dropdown a,
.user-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--muted-color);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.user-dropdown svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 0;
}

.user-dropdown button.logout {
    color: #f87171;
}

.user-dropdown button.logout:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
}

/* Profile page */
.profile-card {
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--habit-done);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    font-weight: 600;
}

.profile-info h2 {
    margin: 0 0 0.25rem 0;
}

.profile-info p {
    margin: 0;
    color: var(--muted-color);
}
