/* Fonts moved to index.html for performance */

:root {
    --primary: #3498db;
    --secondary: #2c3e50;
    --accent-color: #3498db;
    --bg-color: #f0f4f8;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-color: #333333;
    --text-muted: #888888;
    --sidebar-width: 320px;
    --border-color: #eeeeee;
    --button-bg: #ffffff;
    --button-hover: #f9f9f9;
    --incorrect-color: #e74c3c;
    --overlay-bg: rgba(255, 255, 255, 0.4);
}

html {
    background-color: var(--bg-color);
}

:root.dark-mode {
    --bg-color: #0f172a;
    --overlay-bg: rgba(15, 23, 42, 0.85);
    --sidebar-bg: #1e293b;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --secondary: #38bdf8;
    --accent-color: #38bdf8;
    --border-color: #334155;
    --button-bg: #0f172a;
    --button-hover: #334155;
    --incorrect-color: #f87171;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    min-height: 100vh;
    /* background-color removed to allow overlay visibility (html has base color) */
    background-color: transparent;
    color: var(--text-main);
    animation: fadeIn 0.4s ease-out;

    /* Background Image Support */
    background-image: url('../img/backgrounds/bg_light.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    position: relative;
    z-index: 0;
    /* Create stacking context for ::before overlay */
}

/* Overlay for readability */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Reduced opacity to ensure background visibility */
    background: var(--overlay-bg);
    backdrop-filter: blur(3px);
    z-index: -1;
    pointer-events: none;
    /* transition: background 0.3s ease;  <-- Moved to .enable-transitions */
}

/* Overlay handled by variable */

:root.dark-mode body {
    background-image: url('../img/backgrounds/bg_dark.png');
}

/* Global Smooth Transitions */
html.enable-transitions,
html.enable-transitions body,
html.enable-transitions * {
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, background-image 0.5s ease, box-shadow 0.5s ease !important;
}

html.enable-transitions body::before {
    transition: background 0.5s ease;
}

/* Common Classes */
.option-btn {
    padding: 10px;
    border: 2px solid var(--border-color);
    background: var(--button-bg);
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: left;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

button.option-btn:hover {
    background-color: var(--button-hover);
    border-color: var(--border-color);
}

button.option-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: bold;
}

/* Tabs Styles (Ported from profile.css) */
.avatar-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.tab-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

/* Fade In Animation Utility */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-element {
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
    animation-delay: 0.1s;
    /* Slight delay to ensure paint first */
}

/* Staggered children if needed */
.stagger-fade>* {
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}

.stagger-fade>*:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger-fade>*:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger-fade>*:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger-fade>*:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger-fade>*:nth-child(5) {
    animation-delay: 0.5s;
}

/* Custom Text Modal Styles - Mimicking Avatar Selection */
.avatar-option.custom-text-option {
    width: 100%;
    height: auto;
    min-height: 60px;
    padding: 15px 20px;
    justify-content: space-between;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.03);
    border: 2px solid transparent;
    border-radius: 12px;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.avatar-option.custom-text-option:hover {
    background: white;
    transform: scale(1.02);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.custom-text-content {
    flex-grow: 1;
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.avatar-option.custom-text-option .delete-btn {
    background: white;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-left: 10px;
    transition: transform 0.2s;
    opacity: 0.7;
}

.avatar-option.custom-text-option .delete-btn:hover {
    transform: scale(1.1);
    opacity: 1;
    color: #e74c3c;
}

/* Dark Mode Overrides */
body.dark-mode .avatar-option.custom-text-option {
    background: rgba(255, 255, 255, 0.05);
    /* Slight white tint for visibility against dark bg */
    border-color: transparent;
}

body.dark-mode .avatar-option.custom-text-option:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

body.dark-mode .custom-text-content {
    color: #ecf0f1;
}

body.dark-mode .avatar-option.custom-text-option .delete-btn {
    background: #34495e;
    /* Darker circle */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Modal Content Dark Mode (Matches profile.css logic if not globally applied) */
body.dark-mode .modal-content {
    background: #2c3e50;
    color: #ecf0f1;
}

body.dark-mode .tab-btn {
    color: #bdc3c7;
}

body.dark-mode .tab-btn.active {
    color: white;
    /* Primary color handles background */
}

/* Input Fields in Modal */
body.dark-mode #add-text-form {
    background: #34495e !important;
    border-color: #7f8c8d !important;
}

body.dark-mode #new-custom-text,
body.dark-mode #new-custom-type {
    background: #34495e !important;
    /* Force opaque background */
    color: #ecf0f1 !important;
    border: 1px solid #7f8c8d !important;
}

.dedication-footer {
    position: fixed;
    bottom: 10px;
    right: 15px;
    font-size: 1.2rem;
    /* bit larger for caveat */
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
    z-index: 9999;
    font-family: 'Caveat', cursive;
    user-select: none;
}

/* Avatar High-Contrast Styles */
/* Sidebar Avatar */
#user-avatar-display {
    display: inline-flex;
    width: 120px;
    height: 120px;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    font-size: 4.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid white;
}

body.dark-mode #user-avatar-display {
    background: rgba(255, 255, 255, 0.1);
}

/* Dark Mode Modal Button Fixes */
body.dark-mode .option-btn,
body.dark-mode .tab-btn {
    background-color: #34495e;
    color: #ecf0f1;
    border: 1px solid #7f8c8d;
}

body.dark-mode .option-btn:hover,
body.dark-mode .tab-btn:hover {
    background-color: #2c3e50;
    color: white;
}

body.dark-mode .tab-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    border-color: var(--primary);
}

/* Global Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 25px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 10001;
    animation: modalIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-main);
}

@keyframes modalIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- TOOLTIPS --- */
/* --- GLOBAL TOOLTIP (JS Powered) --- */
#global-tooltip {
    position: fixed;
    background: var(--secondary);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: normal;
    max-width: 250px;
    text-align: center;
    line-height: 1.4;
    z-index: 100000;
    /* Above everything */
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(5px);
    /* No arrow for global tooltip to keep it simple and robust */
}

#global-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

body.dark-mode #global-tooltip {
    background: var(--primary);
    color: #0f172a;
    font-weight: bold;
}

/* Page Transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

body {
    animation: fadeIn 0.4s ease-out;
}

body.fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

/* Potentially disable for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    body {
        animation: none;
    }

    body.fade-out {
        animation: none;
    }
}

/* --- TOAST NOTIFICATIONS (Achievements) --- */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    z-index: 20000;
    pointer-events: none;
    /* Allow clicks through empty space */
}

.achievement-toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    /* Enable clicks on toasts */
    border-left: 5px solid #FFD700;
    /* Gold accent */
    transition: opacity 0.3s, transform 0.3s;
}

body.dark-mode .achievement-toast {
    background: rgba(30, 41, 59, 0.95);
    color: #f8fafc;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.toast-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.toast-content {
    flex-grow: 1;
}

.toast-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: #d35400;
    /* Darker orange for light mode */
}

body.dark-mode .toast-title {
    color: #fbbf24;
    /* Amber for dark mode */
}

.toast-desc {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.3;
}

body.dark-mode .toast-desc {
    color: #94a3b8;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #aaa;
    cursor: pointer;
    padding: 0 0 0 10px;
    transition: color 0.2s;
    line-height: 1;
}

.toast-close:hover {
    color: #e74c3c;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Toast Variants */
.achievement-toast.toast-levelup {
    border-left-color: #9b59b6;
    /* Purple */
}

.achievement-toast.toast-levelup .toast-title {
    color: #8e44ad;
}

body.dark-mode .achievement-toast.toast-levelup .toast-title {
    color: #d0aee6;
}

.achievement-toast.toast-complete {
    border-left-color: #2ecc71;
    /* Green */
}

.achievement-toast.toast-complete .toast-title {
    color: #27ae60;
}

body.dark-mode .achievement-toast.toast-complete .toast-title {
    color: #6edc96;
}