/* ============================================
   TIZZY - Modern Light Theme
   Inspired by Vercel, X.com, Linear
   ============================================ */

/* CSS Variables for consistent theming */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #eeeeee;
    --bg-elevated: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-active: #eeeeee;
    
    --border-subtle: rgb(121, 121, 121);
    --border-default: rgb(121, 121, 121);
    --border-strong: rgb(121, 121, 121);
    
    --text-primary: #111111;
    --text-secondary: #444444;
    --text-tertiary: #888888;
    
    --accent-blue: #0070f3;
    --accent-blue-hover: #0060df;
    --accent-green: #00d68f;
    --accent-yellow: #f5a623;
    --accent-red: #e5484d;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Geist Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace;
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    padding-top: calc(56px + env(safe-area-inset-top));
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Helper Classes */
.mobile-break {
    display: none;
}

@media (max-width: 768px) {
    .mobile-break {
        display: block;
    }
}

/* Hamburger Menu */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1002;
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

/* Side Drawer */
.side-drawer {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top) + 8px); /* Below navbar */
    right: 16px;
    width: 220px;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    z-index: 1001;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 100ms ease, transform 100ms ease;
}

.side-drawer.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    /* Keep backdrop behind navbar so logo/header stays crisp */
    z-index: 999;
    transition: opacity 100ms ease;
}

.drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer-links {
    display: flex;
    flex-direction: column;
    padding: 0 6px;
    gap: 2px;
}

.drawer-links a {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 10px 12px;
    border-bottom: none;
    text-decoration: none; /* No underline */
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 100ms ease, color 100ms ease;
}

.drawer-links a:last-child {
    border-bottom: none;
}

.drawer-links a:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

/* Hamburger Animation when Open */
.hamburger.open span {
    display: none; /* Hide spans */
}

.hamburger.open::before,
.hamburger.open::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 10px;
    left: 0;
    top: 50%;
}

.hamburger.open::before {
    transform: rotate(45deg);
}

.hamburger.open::after {
    transform: rotate(-45deg);
}

.hamburger {
    position: relative; /* Ensure pseudo-elements are positioned correctly */
}

a:hover {
    color: var(--text-primary);
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 24px;
    padding-top: env(safe-area-inset-top);
}

.navbar-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.navbar a {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    /* transition: color var(--transition-fast); */
}

.navbar a:hover {
    color: var(--text-primary);
}

/* Header Search */
.header-search {
    display: flex;
    align-items: center;
    position: relative;
    margin-left: auto;
    margin-right: 12px;
}

/* Mini search input (collapsed state) */
.header-search-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    min-width: 140px;
    padding: 0 14px;
    background: var(--bg-hover);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 150ms ease;
    font-family: var(--font-sans);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.header-search-mini:hover {
    background: var(--bg-active);
    border-color: rgba(0, 0, 0, 0.12);
}

.header-search-mini:focus {
    outline: none;
}

.header-search-mini-icon {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.header-search-mini-text {
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search-mini-text.has-query {
    color: var(--text-primary);
    font-weight: 500;
}

@media (max-width: 768px) {
    .header-search-mini-text {
        display: none;
    }
    .header-search-mini {
        width: 42px;
        min-width: 42px;
        padding: 0;
        justify-content: center;
    }
}

.header-search-expanded {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Expanded state - takes over the navbar */
.header-search.expanded {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 16px;
    margin-right: 0;
    animation: searchExpandIn 180ms ease-out;
}

@keyframes searchExpandIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.header-search.expanded .header-search-mini {
    display: none;
}

.header-search.expanded .header-search-expanded {
    position: static;
    left: auto;
    opacity: 1;
    pointer-events: auto;
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 12px;
}

/* Input wrapper with submit button inside */
.header-search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.header-search-input-wrap input {
    width: 100%;
    height: 42px;
    padding: 0 44px 0 14px;
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-lg);
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.header-search-input-wrap input:focus {
    border-color: var(--accent-blue);
    box-shadow: none;
    outline: none;
}

.header-search-input-wrap input::placeholder {
    color: var(--text-tertiary);
}

/* Clear button (circle-x) */
.header-search-clear {
    position: absolute;
    right: 42px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 150ms ease, background 150ms ease;
}

.header-search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.header-search-clear.visible {
    display: flex;
}

/* Magnifying glass submit button */
.header-search-submit {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--accent-blue);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: #fff;
    transition: background 150ms ease, transform 150ms ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.header-search-submit:hover {
    background: var(--accent-blue-hover);
}

.header-search-submit:active {
    transform: translateY(-50%) scale(0.95);
}

.header-search-submit:focus {
    outline: none;
}

.header-search-submit svg {
    flex-shrink: 0;
}

/* Close button */
.header-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: background 150ms ease, color 150ms ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.header-search-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-search-close:focus {
    outline: none;
}

/* Hide logo and menu when search is expanded */
.navbar-content:has(.header-search.expanded) .nav-logo,
.navbar-content:has(.header-search.expanded) .avatar-menu-btn {
    visibility: hidden;
    pointer-events: none;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Cards */
.card-box {
    background: #ededed;
    border-radius: var(--radius-lg);
    padding: 24px;
    /* transition: border-color var(--transition-normal), box-shadow var(--transition-normal); */
}

.card-box:hover {
    border-color: var(--border-default);
}

/* Section Titles */
.section-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: "Cal Sans",sans-serif,helvetica, arial, sans-serif;
    letter-spacing: 0.5px;
}

/* Buttons */
.coolButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 50px;
    padding: 0 20px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: #0070f3;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    /* transition: all var(--transition-fast); */
    width: 100%;
    margin-top: 20px;
}

.coolButton:hover {
    background: #0060df;
    color: #ffffff;
    /* transform: translateY(-1px); */
}

.coolButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Submit Button */
.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    width: 100%;
    padding: 0 20px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: #0070f3;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    /* transition: all var(--transition-fast); */
    margin-top: 20px;
}

.submit-btn:hover {
    background: #0060df;
    color: #ffffff;
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

/* Text Inputs */
.coolTextArea {
    width: 100%;
    min-height: 56px;
    padding: 16px 20px;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid rgb(121, 121, 121);
    border-radius: var(--radius-lg);
    outline: none;
    resize: none;
    /* transition: border-color var(--transition-fast), box-shadow var(--transition-fast); */
    -webkit-user-select: text;
    user-select: text;
    cursor: text;
}


.coolTextArea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.15);
}

.coolTextArea:empty:before {
    content: attr(placeholder);
    color: var(--text-tertiary);
    pointer-events: none;
}

.coolTextArea:focus:before {
    content: none;
}

/* Form Inputs */
.form-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    outline: none;
    /* transition: border-color var(--transition-fast), box-shadow var(--transition-fast); */
}

.form-input:hover {
    border-color: var(--border-default);
}

.form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.15);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

/* Task Cards */
.task-card {
    --task-accent: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 8px;
    /* Paint the status color *inside* the border (not over it) */
    background: linear-gradient(
        to right,
        var(--task-accent) 0 3px,
        var(--bg-elevated) 3px 100%
    );
    background-clip: padding-box;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    /* transition: all var(--transition-fast); */
    position: relative;
    overflow: visible;
}

.task-card:hover {
    background: linear-gradient(
        to right,
        var(--task-accent) 0 3px,
        var(--bg-hover) 3px 100%
    );
    background-clip: padding-box;
    border-color: var(--border-default);
    /* transform: translateX(2px); */
}

.task-description {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 450;
    padding-right: 30px; /* Prevent overlap with menu dots */
}

.task-date {
    font-size: 11px;
    margin-top: 2px;;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* Task Status Colors */
.task-ok { --task-accent: var(--accent-blue); }
.task-upcoming { --task-accent: var(--accent-yellow); }

.page-title {
    font-family: "Cal Sans",sans-serif,helvetica, arial, sans-serif;
    letter-spacing: 0.5px;
}

.task-urgent { --task-accent: var(--accent-red); }
.task-completed { --task-accent: #198754; }

/* Task Card Loading States */
.task-card.is-loading {
    pointer-events: none;
}

.task-card.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    z-index: 10;
    animation: cardLoadingFadeIn 200ms ease-out;
}

.task-card.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--loading-color-light, rgba(0, 112, 243, 0.2));
    border-top-color: var(--loading-color, #0070f3);
    border-radius: 50%;
    z-index: 11;
    animation: cardLoadingSpin 600ms linear infinite, cardLoadingFadeIn 200ms ease-out;
}

/* Loading state color variants */
.task-card.is-loading.loading-delete {
    --loading-color: #dc3545;
    --loading-color-light: rgba(220, 53, 69, 0.2);
}

.task-card.is-loading.loading-complete {
    --loading-color: #198754;
    --loading-color-light: rgba(25, 135, 84, 0.2);
}

.task-card.is-loading.loading-uncomplete {
    --loading-color: #fd7e14;
    --loading-color-light: rgba(253, 126, 20, 0.2);
}

.task-card.is-loading.loading-snooze {
    --loading-color: #0070f3;
    --loading-color-light: rgba(0, 112, 243, 0.2);
}

@keyframes cardLoadingFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cardLoadingSpin {
    to { transform: rotate(360deg); }
}

/* Task Detail Page */
.task-detail-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.bold {
    font-weight: bold !important;
}

.task-detail-due {
    font-size: 14px;
    color: var(--text-secondary);
}

.task-plan-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.task-plan-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.task-plan-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Reminders */
.reminders-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.reminder-card {
    margin-bottom: 16px;
}

.reminder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.reminder-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-blue);
}

.reminder-time {
    font-size: 13px;
    color: var(--text-tertiary);
}

.reminder-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.detail-content {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* iMessage Bubble */
.imessage-bubble {
    background: var(--accent-blue);
    color: #fff;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 100%;
    margin-left: auto;
    position: relative;
}

.imessage-bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -6px;
    width: 12px;
    height: 12px;
    background: var(--accent-blue);
    border-bottom-left-radius: 10px;
    clip-path: polygon(0 0, 0 100%, 100% 100%);
}

/* Generating State */
.generating-plan {
    text-align: center;
    padding: 60px 20px;
}

.generating-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.generating-subtitle {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Loading Spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

/* Text Link */
.text-link {
    color: var(--text-secondary);
    font-size: 14px;
    transition: color var(--transition-fast);
}

.text-link:hover {
    color: var(--text-primary);
}

/* SweetAlert2 Dark Theme */
.swal2-container {
    z-index: 100000 !important; /* Above modals which use z-index: 9999 */
}

.swal2-popup {
    font-family: var(--font-sans) !important;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-lg) !important;
    padding: 24px !important;
}

.swal2-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
}

.swal2-html-container {
    font-size: 14px !important;
    color: var(--text-secondary) !important;
}

.swal2-confirm {
    background: var(--text-primary) !important;
    color: var(--bg-primary) !important;
    font-weight: 500 !important;
    border-radius: var(--radius-md) !important;
    padding: 10px 20px !important;
}

.swal2-cancel {
    font-weight: 500 !important;
    border-radius: var(--radius-md) !important;
    padding: 10px 20px !important;
}

.swal2-confirm.swal-danger {
    background: #dc3545 !important;
    color: #ffffff !important;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 24px 16px;
    }
    
    .card-box {
        padding: 20px;
        border-radius: var(--radius-md);
    }
    
    .reminder-details {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .task-card {
        padding: 14px 16px;
    }
}

/* Fade In Animation Removed */
/*
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}
*/

/* Stagger children animation Removed */
/*
.stagger-children > * {
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }
*/

/* intl-tel-input Dark Mode */
.iti {
    width: 100%;
}

.iti__flag {
    background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.19/img/flags.png");
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .iti__flag {
        background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.19/img/flags@2x.png");
    }
}

.iti__selected-flag {
    padding-left: 16px !important;
    padding-right: 8px !important;
}

.iti__selected-flag .iti__selected-dial-code {
    display: none;
}

.iti__flag-container {
    padding-left: 0px !important;
}

.iti__country-list {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
}

.iti__country.iti__highlight {
    background: var(--bg-hover);
}

.iti__divider {
    border-bottom-color: var(--border-subtle);
}

.iti input[type="tel"] {
    padding-left: 72px !important;
}
