/* dark_theme.css */
:root {
    --bg-color: #f0f9ff; /* Soft Alice Blue */
    --bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); /* Subtle blue gradient */
    --text-color: #1e293b;
    --accent-color: #0369a1; /* Ocean Blue */
    --card-bg: rgba(255, 255, 255, 0.6);
    --hover-bg: #e0f2fe; /* Sky hover */
    --border-color: #bae6fd; /* Muted blue border */
    --input-bg: #ffffff;
    --footer-color: #64748b;
    --theme-rotation: 0deg;
    --palette-glow: rgba(3, 105, 161, 0.25);
}

/* Dark theme overrides */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --text-color: #f8fafc;
    --accent-color: #93c5fd;
    --card-bg: rgba(30, 41, 59, 0.6);
    --hover-bg: #334155;
    --border-color: #334155;
    --input-bg: #1e293b;
    --footer-color: #94a3b8;
    --theme-rotation: 360deg;
    --palette-glow: rgba(147, 197, 253, 0.35);
}

/* Palette: Sepia */
[data-palette="sepia"] {
    --bg-color: #f4ecd8;
    --bg-gradient: linear-gradient(135deg, #f4ecd8 0%, #e7d8b1 100%);
    --text-color: #433422;
    --accent-color: #704214;
    --border-color: #d1bfa7;
    --hover-bg: #eaddcf;
    --palette-glow: rgba(112, 66, 20, 0.25);
}
[data-palette="sepia"][data-theme="dark"] {
    --bg-color: #2b261d;
    --bg-gradient: linear-gradient(135deg, #2b261d 0%, #1a1712 100%);
    --text-color: #d2c1ae;
    --accent-color: #e9c46a;
    --border-color: #4a3f35;
    --hover-bg: #3d352c;
    --palette-glow: rgba(233, 196, 106, 0.35);
}

/* Palette: Mint */
[data-palette="mint"] {
    --bg-color: #f0f7f4;
    --bg-gradient: linear-gradient(135deg, #f0f7f4 0%, #d8eadd 100%);
    --text-color: #1e2d24;
    --accent-color: #065f46;
    --border-color: #c0d6c8;
    --hover-bg: #e2f0e8;
    --palette-glow: rgba(6, 95, 70, 0.25);
}
[data-palette="mint"][data-theme="dark"] {
    --bg-color: #061f17;
    --bg-gradient: linear-gradient(135deg, #061f17 0%, #02120d 100%);
    --text-color: #ecfdf5;
    --accent-color: #34d399;
    --border-color: #064e3b;
    --hover-bg: #065f46;
    --palette-glow: rgba(52, 211, 153, 0.35);
}

/* Global base styles to be inherited by all pages */
body {
    background-color: var(--bg-color);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-color);
    transition: background-color 2s ease, color 2s ease;
}

/* Ensure links are visible and prevent the default dark purple visited color */
a, a:visited {
    color: var(--accent-color);
    transition: color 2s ease;
}

/* Common utility for the header buttons */
.theme-toggle, .logout-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 1.2em;
    border-radius: 50% !important;
    width: 38px;
    height: 38px;
    padding: 0 !important;
    transition: background-color 2s ease, color 2s ease, border-color 2s ease, transform 2s ease, box-shadow 2s ease;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
}

#theme-toggle { transform: rotate(var(--theme-rotation)); }
#palette-toggle { 
    box-shadow: 0 0 12px var(--palette-glow);
    transform: rotate(var(--palette-rotation, 0deg));
    /* Overrides the default transition with a bouncy overshoot */
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Standalone properties (scale/translate) prevent conflict with the 'transform' rotation */
.palette-bounce {
    animation: palette-pop 0.4s ease-out;
}

@keyframes palette-pop {
    0%, 100% { scale: 1; translate: 0 0; }
    50% { scale: 1.25; translate: 0 -5px; }
}

.theme-toggle:hover, .logout-btn:hover {
    border-color: var(--accent-color);
}

#theme-toggle:hover { transform: rotate(var(--theme-rotation)) scale(1.1); }
#palette-toggle:hover { transform: rotate(var(--palette-rotation, 0deg)) scale(1.1); }
.logout-btn:hover { transform: scale(1.1); }

/* Toast Notification */
#toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75); color: #fff; padding: 10px 20px;
    border-radius: 25px; z-index: 5000; font-size: 0.9em;
    opacity: 0; transition: opacity 0.3s, bottom 0.3s; pointer-events: none;
    backdrop-filter: blur(5px); box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-align: center; max-width: 80%;
}

#toast.show {
    opacity: 1;
    bottom: 100px;
}

/* Toast type colors */
#toast.toast-success {
    background: rgba(34, 197, 94, 0.9);
    border: 1px solid rgba(34, 197, 94, 1);
}

#toast.toast-error {
    background: rgba(239, 68, 68, 0.9);
    border: 1px solid rgba(239, 68, 68, 1);
}

#toast.toast-info {
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(100, 116, 139, 0.5);
}

/* Custom Modal Styles */
#est-custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
}
#est-custom-modal.est-show {
    display: flex;
}
.est-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}
.est-modal-content {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 450px;
    width: 90%;
    padding: 24px;
    z-index: 1;
    animation: est-modalSlideIn 0.3s ease-out;
}
@keyframes est-modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.est-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
#est-modal-icon {
    font-size: 28px;
    line-height: 1;
}
.est-modal-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 20px;
    font-weight: 600;
}
.est-modal-body {
    margin-bottom: 20px;
}
.est-modal-body p {
    margin: 0;
    color: var(--text-color);
    line-height: 1.5;
    white-space: pre-line;
    font-size: 16px;
}
.est-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.est-modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.est-modal-btn-cancel {
    background: var(--hover-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.est-modal-btn-cancel:hover {
    background: var(--border-color);
}
.est-modal-btn-confirm {
    background: var(--accent-color);
    color: white;
}
.est-modal-btn-confirm:hover {
    opacity: 0.9;
}
.est-modal-btn:active {
    transform: scale(0.98);
}
/* Mobile responsive modal */
@media (max-width: 600px) {
    .est-modal-content {
        padding: 20px;
        max-width: 90%;
    }
    .est-modal-footer {
        flex-direction: column-reverse;
    }
    .est-modal-btn {
        width: 100%;
        padding: 12px;
    }
}

/* Format selection popups/dropdowns */
.dropdown-content, .format-popup, .dropdown-menu {
    background: var(--bg-color) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.dropdown-content a, .format-popup a, .dropdown-menu a {
    color: var(--text-color) !important;
    text-decoration: none;
    display: block;
    padding: 10px 15px;
}

.dropdown-content a:hover, .dropdown-content a:active,
.format-popup a:active, .dropdown-menu a:active {
    background-color: var(--hover-bg) !important;
    color: var(--accent-color) !important;
}