@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap');

/* ===== Base ===== */
body {
    font-family: 'Inter', sans-serif;
    background-color: #F8FAFC;
    padding: 0;
    margin: 0;
}

/* Hide scrollbar but keep scrollable */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ===== App Header ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #F1F5F9;
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    color: #94A3B8;
    border: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 0.8125rem;
    cursor: pointer;
}
.header-icon-btn:hover { color: #14B8A6; }

.header-avatar {
    height: 36px;
    padding: 0 12px;
    border-radius: 9999px;
    background: #F0FDFA;
    border: 1px solid #CCFBF1;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Tab Views ===== */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.tab-view {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: viewFadeIn 0.2s ease-out;
}
.tab-view.active {
    display: flex;
}

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

/* Glass panel */
.glass-panel {
    background: #FFFFFF;
    border-radius: 1.25rem;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.02), 0 8px 10px -6px rgba(0,0,0,0.01);
    border: 1px solid #F1F5F9;
    transition: box-shadow 0.3s ease;
}
.glass-panel:hover {
    box-shadow: 0 12px 30px -5px rgba(0,0,0,0.04), 0 10px 14px -6px rgba(0,0,0,0.02);
}

/* ===== Bottom Navigation ===== */
.mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid #F1F5F9;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 45;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.03);
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 0;
    flex: 1;
    color: #94A3B8;
    font-size: 0.625rem;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    background: none;
    border: none;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.nav-tab i {
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

.nav-tab.active {
    color: #14B8A6;
}

.nav-tab.active i {
    transform: scale(1.1);
}

.nav-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 24px;
    height: 2.5px;
    border-radius: 0 0 4px 4px;
    background: #14B8A6;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-tab.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-tab:active {
    transform: scale(0.92);
}

/* ===== Calendar ===== */
.cal-cell {
    padding: 6px 0;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
    user-select: none;
}
.cal-cell:hover { background: #F8FAFC; }
.cal-cell.today {
    background: #F43F5E;
    color: #fff;
    box-shadow: 0 4px 12px rgba(244,63,94,0.25);
}
.cal-cell.today:hover { background: #E11D48; }
.cal-cell.selected {
    background: #F0FDFA;
    color: #0D9488;
    border: 1px solid #99F6E4;
}
.cal-cell.other-month { color: #CBD5E1; }
.cal-cell .cal-dot {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #2DD4BF;
}
.cal-cell.today .cal-dot { background: #fff; }

/* ===== Todo ===== */
.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
}
.todo-item:hover {
    background: #F8FAFC;
    border-color: #F1F5F9;
}
.todo-item.done .todo-title {
    text-decoration: line-through;
    color: #94A3B8;
}
.todo-item .todo-checkbox {
    margin-top: 2px;
    width: 20px;
    height: 20px;
    accent-color: #14B8A6;
    cursor: pointer;
}
.todo-item .todo-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.4;
}
.todo-item .todo-meta {
    font-size: 0.75rem;
    margin-top: 3px;
}
.todo-filter-btn.active {
    background: #F1F5F9 !important;
    color: #475569 !important;
}

/* Todo delete button */
.todo-item .todo-delete {
    opacity: 0;
    transition: opacity 0.15s ease;
    margin-left: auto;
    flex-shrink: 0;
}
.todo-item:hover .todo-delete { opacity: 1; }

/* ===== Stats bars ===== */
.stat-bar-wrapper {
    width: 100%;
    background: #F1F5F9;
    border-radius: 4px 4px 0 0;
    position: relative;
}
.stat-bar {
    position: absolute;
    bottom: 0;
    width: 100%;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease, background 0.3s ease;
}
.stat-bar:hover { filter: brightness(1.08); }
.stat-bar.today-bar { box-shadow: 0 4px 12px rgba(20,184,166,0.25); }

/* ===== Habits ===== */
.habit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid;
    transition: all 0.2s ease;
}
.habit-item .habit-check-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.habit-item .habit-check-btn:hover {
    transform: scale(1.1);
}
.habit-item .habit-check-btn.checked {
    animation: checkBounce 0.3s ease;
}
@keyframes checkBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Habit delete button */
.habit-item .habit-delete {
    opacity: 0;
    transition: opacity 0.15s ease;
}
.habit-item:hover .habit-delete { opacity: 1; }

/* ===== Pomodoro ===== */
.pomo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
}
.pomo-dot.filled { background: #F43F5E; box-shadow: 0 2px 6px rgba(244,63,94,0.3); }
.pomo-dot.empty  { background: #E2E8F0; }

/* ===== Modal ===== */
#modal-overlay.show { display: flex !important; }
#modal-overlay.show #modal-content {
    transform: scale(1);
    opacity: 1;
}
.modal-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    font-size: 0.875rem;
    color: #334155;
    outline: none;
    transition: border-color 0.2s ease;
}
.modal-input:focus {
    border-color: #14B8A6;
    box-shadow: 0 0 0 3px rgba(20,184,166,0.1);
}
.modal-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748B;
    margin-bottom: 6px;
}
.modal-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    font-size: 0.875rem;
    color: #334155;
    background: #fff;
    outline: none;
    cursor: pointer;
}
.modal-select:focus {
    border-color: #14B8A6;
}

/* ===== Toast ===== */
.toast {
    background: #334155;
    color: #fff;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    pointer-events: auto;
    animation: toastIn 0.3s ease forwards;
    max-width: 300px;
}
.toast.toast-out {
    animation: toastOut 0.25s ease forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ===== Tabular nums for timer ===== */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* ==================================================
   MOBILE LAYOUT (< 1024px)
   ================================================== */
@media (max-width: 1023px) {
    body {
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .app-main {
        flex: 1;
        min-height: 0;
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    .tab-view {
        padding: 12px 14px 16px;
    }

    .glass-panel {
        border-radius: 1rem;
    }

    /* Pomodoro fills available space on mobile */
    .pomodoro-mobile {
        flex: 1;
        min-height: 0;
        justify-content: center;
    }

    /* Todo & Habits scrollable */
    #todo-panel {
        min-height: 200px;
    }
    #habits-panel {
        min-height: 160px;
    }

    /* Touch-friendly: show delete on mobile always (no hover) */
    .todo-item .todo-delete,
    .habit-item .habit-delete {
        opacity: 0.5;
    }

    /* Smaller timer ring on small mobile */
    @media (max-width: 400px) {
        #pomo-time { font-size: 2.5rem !important; }
    }
}

/* ==================================================
   DESKTOP LAYOUT (≥ 1024px)
   ================================================== */
@media (min-width: 1024px) {
    body {
        padding: 24px 32px;
        height: 100vh;
    }

    .app-header {
        position: relative;
        background: transparent;
        backdrop-filter: none;
        border-bottom: none;
        padding: 0;
        margin-bottom: 24px;
    }

    /* Hide mobile nav on desktop */
    .mobile-nav {
        display: none !important;
    }

    /* Desktop: show all views in 3-column grid */
    .app-main {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 24px;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    /* Override: show all tab-views on desktop */
    .tab-view {
        display: flex !important;
        padding: 0;
        overflow-y: auto;
        animation: none;
    }

    /* Left column: Today (Calendar + Todo) — spans both rows */
    #view-today {
        grid-column: 1;
        grid-row: 1 / -1;
    }

    /* Center column: Focus (Pomodoro) — spans both rows */
    #view-focus {
        grid-column: 2;
        grid-row: 1 / -1;
    }
    #view-focus #pomodoro-panel {
        flex: 1;
    }

    /* Right column top: Habits */
    #view-habits {
        grid-column: 3;
        grid-row: 1;
    }

    /* Right column bottom: Stats */
    #view-stats {
        grid-column: 3;
        grid-row: 2;
    }

    .header-icon-btn {
        width: 40px;
        height: 40px;
    }

    .header-avatar {
        height: 40px;
        padding: 0 16px;
    }
}
