:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Kanit', 'Inter', sans-serif;
    background: var(--bg-darker);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* ------------------------
   Loading Overlay
------------------------ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* ------------------------
   Secret Login Button
------------------------ */
.secret-login-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.secret-login-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    transform: scale(1.1);
}

/* ------------------------
   Public Bio Link View
------------------------ */
.bio-container {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1.5rem;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-section {
    text-align: center;
    margin-bottom: 2.5rem;
}

.profile-pic {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    margin: 0 auto 1.2rem;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    background: linear-gradient(45deg, var(--accent), #8b5cf6);
}

.profile-name {
    font-weight: 600;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.profile-bio {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}

.links-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    margin-bottom: 3rem;
}

.link-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1.1rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    text-decoration: none;
    border-radius: 30px;
    font-weight: 500;
    font-size: 1.05rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.link-btn i {
    position: absolute;
    left: 1.5rem;
    font-size: 1.3rem;
}

.link-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.loading-links {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* ------------------------
   Dashboard Layout (Private)
------------------------ */
.dashboard-grid {
    width: 100%;
    max-width: 1280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--glass-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-brand i {
    color: var(--accent);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#user-name {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

/* Panels Layout */
.panels-layout {
    display: flex;
    gap: 1.5rem;
    flex: 1;
}

/* Calendar Bar (Top) */
.calendar-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.5rem;
    gap: 1rem;
}

.calendar-days {
    display: flex;
    flex: 1;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    /* Firefox */
    padding: 0.2rem 0;
    scroll-behavior: smooth;
}

.calendar-days::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.cal-day-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    height: 55px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.cal-day-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.cal-day-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.cal-day-btn.has-entry::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #10b981;
    /* Green dot */
    border-radius: 50%;
    margin-top: 4px;
    position: absolute;
    bottom: 6px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--success);
}

.cal-day-btn.active.has-entry::after {
    background-color: white;
}

.cal-day-weekday {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.cal-day-date {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Panels */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Left Panel - Journal */
.journal-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

/* Custom Scrollbar */
.journal-panel::-webkit-scrollbar,
.scrollable::-webkit-scrollbar {
    width: 6px;
}

.journal-panel::-webkit-scrollbar-track,
.scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.journal-panel::-webkit-scrollbar-thumb,
.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h2 {
    font-size: 1.4rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-header h2 i {
    color: var(--accent);
    font-size: 1.1rem;
}

.date-picker {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

.date-picker::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Form Controls */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-weight: 400;
}

/* Habit Tracker */
.habits-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.habit-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.habit-item:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.habit-item input[type="checkbox"] {
    display: none;
}

.habit-checkmark {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.habit-item input:checked+.habit-checkmark {
    background: var(--success);
    border-color: var(--success);
}

.habit-item input:checked+.habit-checkmark::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
    color: white;
}

.habit-item.checked {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

/* Feeling Selector */
.emoji-selector {
    display: flex;
    gap: 1rem;
}

.emoji-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    font-size: 1.8rem;
    padding: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    filter: grayscale(1);
    opacity: 0.6;
}

.emoji-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.emoji-btn.active {
    filter: grayscale(0);
    opacity: 1;
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.1);
}

/* Custom Emotion Tags */
.emotion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.emotion-tag {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.emotion-tag:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-main);
}

.emotion-tag.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent);
    color: var(--text-main);
}

.emotion-tag.add-tag {
    border-style: dashed;
}

.emotion-tag.add-tag:hover {
    background: rgba(255, 255, 255, 0.05);
}


/* Goals */
.goals-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
}

.goals-list {
    list-style: none;
    margin-bottom: 0.5rem;
}

.goals-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.goals-list li:last-child {
    border-bottom: none;
}

.goal-text {
    font-size: 0.95rem;
}

.remove-goal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.remove-goal:hover {
    color: var(--danger);
}

.goal-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-muted);
}

.goal-input-wrapper input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    outline: none;
}

.goal-input-wrapper input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Textarea */
.flex-grow {
    flex: 1;
    min-height: 200px;
}

textarea {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.2rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

/* Custom Sliders */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    transition: background 0.2s;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover,
.slider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

/* Footer */
.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.status-msg {
    font-size: 0.9rem;
}

.success {
    color: var(--success);
}

.error {
    color: var(--danger);
}

.btn {
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s, transform 0.2s;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Right Panel - Google Overview & Settings */
.overview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 330px;
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
}

.widget {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Let Calendar and tasks dictate their own heights slightly, but settings is mostly fixed */
.widget:not(:first-child) {
    flex: 1;
}

.widget-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.widget-header h3 i {
    color: var(--text-muted);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
}

.widget-content {
    flex: 1;
    padding: 0;
}

.widget-content.padded {
    padding: 1rem;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.empty-state.error {
    color: var(--danger);
}

.empty-state.warning {
    color: var(--warning);
}

.loading {
    padding: 2rem;
    text-align: center;
    color: var(--accent);
    font-size: 0.9rem;
}

/* Google Lists Styles */
.google-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.google-list li {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.2s;
}

.google-list li:hover {
    background: rgba(255, 255, 255, 0.02);
}

.google-list li:last-child {
    border-bottom: none;
}

.item-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 50px;
    padding-top: 0.2rem;
}

.item-content {
    flex: 1;
}

.item-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.item-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Tasks specifically */
.tasks-style li {
    align-items: flex-start;
}

.task-icon {
    color: var(--text-muted);
    padding-top: 0.3rem;
}

.task-item:hover .task-icon {
    color: var(--success);
}

/* Links Manager Styles */
.add-link-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.small-input {
    flex: 1;
    min-width: 100px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
}

.small-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.action-btn {
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.small-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.action-btn.primary {
    background: var(--accent);
    color: white;
}

.action-btn.primary:hover {
    background: var(--accent-hover);
}

.manage-list {
    list-style: none;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
}

.manage-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    margin-bottom: 0.4rem;
}

.link-info-sm {
    font-size: 0.85rem;
    line-height: 1.3;
}

.link-info-sm i {
    width: 16px;
    text-align: center;
    margin-right: 4px;
    color: var(--text-muted);
}

.link-info-sm small {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
}

.status-sm {
    text-align: right;
    font-size: 0.8rem;
    height: 1.2rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-wrapper {
        overflow: auto;
    }

    .panels-layout {
        flex-direction: column;
        overflow: visible;
    }

    .dashboard-grid {
        height: auto;
        min-height: 100vh;
    }

    .journal-panel,
    .overview-panel {
        flex: none;
        width: 100%;
    }

    .widget {
        min-height: 300px;
    }
}

/* =========================================
   Custom Modals (Glassmorphism Overlays)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    background: rgba(15, 23, 42, 0.85);
    /* Darker panel */
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.9);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
}

/* Modal specific inputs */
.modal-body .manage-list {
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.modal-body .manage-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.modal-body .manage-list li:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.habit-details {
    display: flex;
    flex-direction: column;
}

.habit-details span {
    font-weight: 500;
}

.habit-details small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Stats Bars */
.stat-row {
    margin-bottom: 1.2rem;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.stat-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 10px;
    width: 0%;
    /* Dynamic */
    transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}