/* Online Journal - Custom Styles */

/* Base transitions */
* {
    -webkit-tap-highlight-color: transparent;
}

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #C4A77D;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8B7355;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4A3F30;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6B5A45;
}

/* Focus styles */
input:focus, textarea:focus, button:focus {
    outline: none;
}

/* Transition overlay animation */
#transition-overlay {
    transition: opacity 0.5s ease-in-out;
}

#transition-overlay.fade-out {
    opacity: 0;
}

/* Page content animations */
.page-enter {
    animation: pageEnter 0.3s ease-out forwards;
}

.page-exit {
    animation: pageExit 0.2s ease-in forwards;
}

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

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

/* Mood selector */
.mood-selector {
    display: flex;
    gap: 0.5rem;
}

.mood-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: #F5F1EB;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark .mood-btn {
    background: #252219;
}

.mood-btn:hover {
    transform: scale(1.1);
    border-color: #C4A77D;
}

.mood-btn.selected {
    border-color: #8B7355;
    background: #C4A77D;
    transform: scale(1.15);
}

.dark .mood-btn.selected {
    background: #4A3F30;
    border-color: #C4A77D;
}

/* Task checkbox animation */
.task-checkbox {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #C4A77D;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.task-checkbox:checked {
    background: #8B7355;
    border-color: #8B7355;
}

.task-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    animation: checkmark 0.2s ease-out;
}

@keyframes checkmark {
    from {
        transform: rotate(45deg) scale(0);
    }
    to {
        transform: rotate(45deg) scale(1);
    }
}

.dark .task-checkbox {
    border-color: #6B5A45;
}

.dark .task-checkbox:checked {
    background: #C4A77D;
    border-color: #C4A77D;
}

/* Task text strikethrough */
.task-text.completed {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Habit tracking dots */
.habit-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #E8DCC8;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.habit-dot:hover {
    transform: scale(1.1);
    border-color: #C4A77D;
}

.habit-dot.completed {
    background: #8B7355;
    border-color: #8B7355;
}

.habit-dot.completed::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.dark .habit-dot {
    border-color: #4A3F30;
}

.dark .habit-dot.completed {
    background: #C4A77D;
    border-color: #C4A77D;
}

.dark .habit-dot.completed::after {
    color: #1A1814;
}

.habit-dot.future {
    opacity: 0.35;
    cursor: not-allowed;
}

.dark .habit-dot.future {
    opacity: 0.25;
}

.negative-habit-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2.5px solid #ef4444;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.negative-habit-dot:hover {
    border-color: #ef4444;
}

.negative-habit-dot.checked {
    background: #ef4444;
    border-color: #ef4444;
}

.negative-habit-dot.checked::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.dark .negative-habit-dot {
    border-color: #f87171;
}

.dark .negative-habit-dot:hover {
    border-color: #f87171;
}

.dark .negative-habit-dot.checked {
    background: #dc2626;
    border-color: #dc2626;
}

.dark .negative-habit-dot.checked::after {
    color: white;
}

/* Habit progress bar */
.habit-progress {
    height: 6px;
    background: #E8DCC8;
    border-radius: 3px;
    overflow: hidden;
}

.habit-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #8B7355, #C4A77D);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.dark .habit-progress {
    background: #4A3F30;
}

/* Card styles */
.card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dark .card {
    background: #252219;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.dark .card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Input and textarea styles */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid #E8DCC8;
    background: #FAF7F2;
    transition: all 0.2s ease;
}

.input-field:focus {
    border-color: #C4A77D;
    box-shadow: 0 0 0 3px rgba(196, 167, 125, 0.2);
}

.dark .input-field {
    background: #1A1814;
    border-color: #4A3F30;
    color: #F5F1EB;
}

.dark .input-field:focus {
    border-color: #C4A77D;
    box-shadow: 0 0 0 3px rgba(196, 167, 125, 0.1);
}

.input-field::placeholder {
    color: #9CA3AF;
}

.dark .input-field::placeholder {
    color: #6B6B6B;
}

/* Textarea auto-resize helper */
textarea.input-field {
    min-height: 100px;
    resize: vertical;
}

/* Button styles */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #8B7355;
    color: white;
}

.btn-primary:hover {
    background: #6B5A45;
}

.dark .btn-primary {
    background: #C4A77D;
    color: #1A1814;
}

.dark .btn-primary:hover {
    background: #D4C4A8;
}

.btn-secondary {
    background: #E8DCC8;
    color: #6B5A45;
}

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

.dark .btn-secondary {
    background: #4A3F30;
    color: #E8DCC8;
}

.dark .btn-secondary:hover {
    background: #6B5A45;
}

/* Navigation active state */
.nav-link.active {
    background: #F5F1EB;
    color: #8B7355;
    font-weight: 500;
}

.dark .nav-link.active {
    background: #4A3F30;
    color: #C4A77D;
}

/* Free thoughts card */
.thought-card {
    border-left: 3px solid #C4A77D;
    padding-left: 1rem;
}

/* Stats card */
.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: #8B7355;
}

.dark .stat-value {
    color: #C4A77D;
}

.stat-label {
    font-size: 0.875rem;
    color: #9CA3AF;
    margin-top: 0.25rem;
}

/* Date header */
.date-header {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.5rem;
    color: #6B5A45;
}

.dark .date-header {
    color: #E8DCC8;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #9CA3AF;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #F5F1EB 25%, #E8DCC8 50%, #F5F1EB 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

.dark .skeleton {
    background: linear-gradient(90deg, #252219 25%, #4A3F30 50%, #252219 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    background: #252219;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: #059669;
}

.toast.error {
    background: #DC2626;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .mood-btn {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .habit-dot {
        width: 24px;
        height: 24px;
    }

    .habit-dot.completed::after {
        font-size: 12px;
    }

    .card {
        padding: 1rem;
    }

    .date-header {
        font-size: 1.25rem;
    }
}

/* Print styles */
@media print {
    #sidebar, #mobile-menu-btn, .btn {
        display: none !important;
    }

    main {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #E8DCC8;
    }
}

/* ========== THEME CSS VARIABLES ========== */
:root {
    --color-theme-50: #FAF7F2;
    --color-theme-100: #F5F1EB;
    --color-theme-200: #E8DCC8;
    --color-theme-300: #D4C4A8;
    --color-theme-400: #C4A77D;
    --color-theme-500: #8B7355;
    --color-theme-600: #6B5A45;
    --color-theme-700: #4A3F30;
    --color-theme-800: #252219;
    --color-theme-900: #1A1814;
    --color-accent: #8B7355;
    --color-accent-light: #C4A77D;
}

/* ========== CARD GRADIENTS ========== */
.card-gradient {
    background: linear-gradient(135deg,
        var(--color-theme-100) 0%,
        var(--color-theme-50) 100%);
}

.dark .card-gradient {
    background: linear-gradient(135deg,
        var(--color-theme-800) 0%,
        var(--color-theme-900) 100%);
}

/* ========== BACKGROUND PATTERN ========== */
body {
    background-image:
        radial-gradient(circle at 15% 15%, rgba(139, 115, 85, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(196, 167, 125, 0.04) 0%, transparent 40%);
    background-attachment: fixed;
}

.dark body {
    background-image:
        radial-gradient(circle at 15% 15%, rgba(196, 167, 125, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(139, 115, 85, 0.03) 0%, transparent 40%);
}

/* ========== ANIMATED MOOD SELECTOR ========== */
.mood-btn {
    position: relative;
    overflow: visible;
}

.mood-btn::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-accent-light) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    z-index: -1;
}

.mood-btn:hover::before {
    opacity: 0.4;
    transform: scale(1.3);
}

.mood-btn.selected::before {
    opacity: 0.6;
    transform: scale(1.4);
    animation: mood-glow 2s ease-in-out infinite;
}

@keyframes mood-glow {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1.3);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.5);
    }
}

/* ========== NAVIGATION BADGES ========== */
.nav-link {
    position: relative;
}

.nav-badge {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #EF4444;
    border-radius: 50%;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-50%) scale(1.4);
        opacity: 0.6;
    }
}

/* ========== CIRCULAR PROGRESS ========== */
.circular-progress {
    transform: rotate(-90deg);
}

.circular-progress .circle-bg {
    fill: none;
    stroke: var(--color-theme-200);
    stroke-width: 3.5;
}

.dark .circular-progress .circle-bg {
    stroke: var(--color-theme-700);
}

.circular-progress .circle {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 3.5;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== SKELETON LOADING IMPROVEMENTS ========== */
.skeleton-text {
    height: 1em;
    display: inline-block;
}

.skeleton-circle {
    border-radius: 50%;
}

/* ========== SAVING INDICATOR ========== */
.saving-indicator {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.625rem 1.25rem;
    background: var(--color-theme-700);
    color: white;
    border-radius: 9999px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.saving-indicator.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.saving-indicator .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== DRAG AND DROP ========== */
.draggable {
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    user-select: none;
}

.draggable:active {
    cursor: grabbing;
}

.draggable.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.draggable.drag-over {
    border-top: 2px solid var(--color-accent);
}

.drag-handle {
    cursor: grab;
    opacity: 0.3;
    transition: opacity 0.2s ease;
    touch-action: none;
}

.draggable:hover .drag-handle {
    opacity: 0.7;
}

/* ========== FLOATING ACTION BUTTON ========== */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 40;
    border: none;
    cursor: pointer;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.fab:active {
    transform: scale(0.95);
}

.fab.open {
    transform: rotate(45deg);
}

.fab-menu {
    position: fixed;
    bottom: 6.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 39;
}

.fab-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-theme-700);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.fab-menu-item:hover {
    transform: translateX(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.dark .fab-menu-item {
    background: var(--color-theme-800);
    color: var(--color-theme-200);
}

/* ========== HEATMAP STYLES ========== */
.heatmap-container {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(53, 1fr);
    gap: 3px;
    min-width: 700px;
}

.heatmap-cell {
    aspect-ratio: 1;
    min-width: 12px;
    border-radius: 2px;
    background: var(--color-theme-100);
    transition: all 0.2s ease;
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.3);
    z-index: 1;
}

.dark .heatmap-cell {
    background: var(--color-theme-800);
}

.heatmap-cell.level-0 {
    background: var(--color-theme-100);
}
.dark .heatmap-cell.level-0 {
    background: var(--color-theme-800);
}

.heatmap-cell.level-1 {
    background: #9BE9A8;
}
.heatmap-cell.level-2 {
    background: #40C463;
}
.heatmap-cell.level-3 {
    background: #30A14E;
}
.heatmap-cell.level-4 {
    background: #216E39;
}

/* ========== ENHANCED PAGE TRANSITIONS ========== */
.page-enter {
    animation: pageEnterEnhanced 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-exit {
    animation: pageExitEnhanced 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

@keyframes pageExitEnhanced {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
}

/* ========== THEME SELECTOR ========== */
.theme-selector {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.theme-option {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.theme-option:hover {
    transform: scale(1.1);
}

.theme-option.selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color-accent);
}

.dark .theme-option.selected {
    box-shadow: 0 0 0 2px var(--color-theme-900), 0 0 0 4px var(--color-accent);
}

.theme-option-inner {
    position: absolute;
    inset: 0;
    display: flex;
}

.theme-option-light,
.theme-option-dark {
    flex: 1;
}

/* ========== KEYBOARD SHORTCUTS HINT ========== */
.kbd {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-family: ui-monospace, monospace;
    background: var(--color-theme-100);
    border: 1px solid var(--color-theme-300);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--color-theme-300);
    color: var(--color-theme-600);
}

.dark .kbd {
    background: var(--color-theme-800);
    border-color: var(--color-theme-600);
    box-shadow: 0 1px 0 var(--color-theme-700);
    color: var(--color-theme-300);
}

/* ========== TOOLTIP ========== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 0.5rem 0.75rem;
    background: var(--color-theme-800);
    color: white;
    font-size: 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 50;
}

.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ========== EMPTY STATE IMPROVEMENTS ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-theme-600);
    margin-bottom: 0.5rem;
}

.dark .empty-state-title {
    color: var(--color-theme-300);
}

.empty-state-text {
    color: var(--color-theme-400);
    margin-bottom: 1.5rem;
}

/* ========== BUTTON DISABLED STATE ========== */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== STREAK ANIMATION ========== */
@keyframes streak-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.streak-active {
    animation: streak-pulse 2s ease-in-out infinite;
}

/* ========== RESPONSIVE IMPROVEMENTS ========== */
@media (max-width: 640px) {
    .fab {
        width: 48px;
        height: 48px;
        bottom: 1rem;
        right: 1rem;
    }

    .fab-menu {
        bottom: 5rem;
        right: 1rem;
    }

    .saving-indicator {
        bottom: 1rem;
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }

    .heatmap-grid {
        gap: 2px;
    }

    .heatmap-cell {
        min-width: 10px;
    }
}
