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

:root {
    /* BASE THEME (LIGHT) */
    --bg-color: #FDFDFD;
    --text-color: #111827;
    --primary: #4F46E5;
    --primary-hover: #4338CA;

    --color-0-20: rgba(250, 204, 21, 0.4);
    --color-20-65: rgba(74, 222, 128, 0.4);
    --color-65-75: rgba(248, 113, 113, 0.4);

    --rate-1: #E11D48;
    --rate-2: #F43F5E;
    --rate-3: #D1D5DB;
    --rate-4: #FBBF24;
    --rate-5: #34D399;
    --rate-6: #10B981;
    --rate-pre: #121418;
    --rate-miss: #5e5e5e;
    --rate-future: #ffffff;

    --nav-bg: rgba(255, 255, 255, 0.9);
    --card-bg: #FFFFFF;
    --card-border: rgba(229, 231, 235, 1);
    --modal-bg: rgba(255, 255, 255, 0.85);

    --head-grad-1: #111827;
    --head-grad-2: #4B5563;
    --subtext: #6B7280;
    --close-btn: #F3F4F6;

    --nav-height: 65px;
}

[data-theme="dark"] {
    --bg-color: #0F172A;
    --text-color: #F8FAFC;
    --primary: #6366F1;
    --primary-hover: #4F46E5;

    --rate-pre: #334155;
    --rate-miss: #475569;
    --rate-future: #1E293B;
    --rate-3: #64748B;

    --nav-bg: rgba(15, 23, 42, 0.95);
    --card-bg: #1E293B;
    --card-border: rgba(255, 255, 255, 0.1);
    --modal-bg: rgba(30, 41, 59, 0.9);

    --head-grad-1: #F8FAFC;
    --head-grad-2: #94A3B8;
    --subtext: #94A3B8;
    --close-btn: #334155;

    /* Slightly less aggressive colors for dark theme */
    --color-0-20: rgba(250, 204, 21, 0.25);
    --color-20-65: rgba(74, 222, 128, 0.25);
    --color-65-75: rgba(248, 113, 113, 0.25);
}

[data-theme="ocean"] {
    --bg-color: #F0F9FF;
    --text-color: #0C4A6E;
    --primary: #0284C7;
    --primary-hover: #0369A1;
    --rate-future: #E0F2FE;
    --nav-bg: rgba(240, 249, 255, 0.9);

    --card-bg: #FFFFFF;
    --card-border: rgba(14, 165, 233, 0.2);
    --modal-bg: rgba(255, 255, 255, 0.9);

    --head-grad-1: #0C4A6E;
    --head-grad-2: #0284C7;
    --subtext: #0284C7;
    --close-btn: #E0F2FE;
}

[data-theme="sunset"] {
    --bg-color: #FFF1F2;
    --text-color: #881337;
    --primary: #E11D48;
    --primary-hover: #BE123C;
    --rate-future: #FFE4E6;
    --nav-bg: rgba(255, 241, 242, 0.9);

    --card-bg: #FFFFFF;
    --card-border: rgba(225, 29, 72, 0.2);
    --modal-bg: rgba(255, 255, 255, 0.9);

    --head-grad-1: #881337;
    --head-grad-2: #E11D48;
    --subtext: #BE123C;
    --close-btn: #FFE4E6;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    touch-action: auto !important;
    /* Allow native zoom */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    padding-bottom: var(--nav-height);
}

/* VIEWS */
.view {
    display: none;
    padding: 20px 15px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--card-border);
}

.view-header h2 {
    font-size: 22px;
    margin: 0;
}

/* BUTTONS */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-color);
    border: none;
    padding: 8px 0;
    font-weight: 600;
    cursor: pointer;
}

h1 {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 25px;
    background: linear-gradient(135deg, var(--head-grad-1), var(--head-grad-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* BOTTOM NAVIGATION */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 900;
}

.nav-item {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--subtext);
    font-size: 20px;
    cursor: pointer;
    flex: 1;
    height: 100%;
    transition: all 0.2s;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
    font-family: 'Outfit';
}

.nav-item.active {
    color: var(--primary);
}

/* NOTES MODULE */
.notes-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-color);
}

.note-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.note-card h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-color);
}

.note-card .date {
    font-size: 12px;
    color: var(--subtext);
}

/* NOTE EDITOR */
.editor-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 100vh;
    background: var(--bg-color);
    z-index: 1000;
}

.note-title-input {
    width: 100%;
    border: none;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    outline: none;
    background: transparent;
    font-family: inherit;
    color: var(--text-color);
}

/* CKEditor adjustments for dark theme mainly handled internally via its css, 
   but we can style the container slightly */
.ck-editor__editable_inline {
    min-height: calc(100vh - 160px) !important;
    border-bottom-left-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--card-border) !important;
}

.ck-toolbar {
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
}

.ck.ck-editor__main>.ck-editor__editable:not(.ck-focused) {
    border-color: var(--card-border) !important;
}

[data-theme="dark"] .ck-toolbar .ck-button {
    color: var(--text-color) !important;
}

[data-theme="dark"] .ck-toolbar .ck-button:hover {
    background: var(--rate-pre) !important;
}

[data-theme="dark"] .ck-dropdown__panel {
    background: var(--card-bg) !important;
    border-color: var(--card-border) !important;
}

[data-theme="dark"] .ck-list__item {
    color: var(--text-color) !important;
}


/* CALENDAR MODULE */
.year-wrapper {
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 15px;
    transition: opacity 0.3s ease;
}

.year-label {
    width: 25px;
    text-align: right;
    margin-right: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--subtext);
    padding-top: 1px;
    flex-shrink: 0;
}

.year-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 1px;
    flex: 1;
    width: 100%;
}

.day {
    flex: 1 1 0;
    min-width: 0;
    height: 7px;
    border-radius: 1px;
    background-color: var(--rate-future);
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    overflow: hidden;
}

.day .cross {
    font-size: 7px;
    line-height: 7px;
    font-weight: 800;
    color: var(--rate-1);
    /* Red cross */
    transform: scale(0.9);
}

/* WEEK WIDGET */
.week-widget {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: var(--nav-bg);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* MONTH GRID STYLE */
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.month-day {
    aspect-ratio: 1;
    border-radius: 8px;
    background-color: var(--rate-future);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid var(--card-border);
}

.month-day:active {
    transform: scale(0.95);
}

.month-day.today {
    border: 2px solid var(--primary);
    font-weight: 800;
}

.month-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 5px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--subtext);
}

.week-day-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 50px;
    border-radius: 8px;
    background-color: var(--rate-future);
    color: var(--text-color);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.week-day-btn:active {
    transform: scale(0.9);
}

.week-day-btn.today {
    border: 2px solid var(--primary);
}

.week-day-btn .w-name {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--subtext);
}

.week-day-btn .w-num {
    font-size: 14px;
    font-weight: 800;
}

.day.today {
    border: 1.5px solid var(--text-color);
    z-index: 5;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(17, 24, 39, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 4px rgba(17, 24, 39, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(17, 24, 39, 0);
    }
}

.day:hover {
    transform: scale(2.5) translateY(-2px);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 10;
    border-radius: 2px;
}

/* Zone colors applied directly to the days instead of the container background */
.zone-1 .day {
    background-color: var(--color-0-20);
}

.zone-2 .day {
    background-color: var(--color-20-65);
}

.zone-3 .day {
    background-color: var(--color-65-75);
}

/* Overrides for completed patterns */
.zone-1 .day.black,
.zone-2 .day.black,
.zone-3 .day.black {
    background-color: var(--rate-pre);
}

.zone-1 .day.missing,
.zone-2 .day.missing,
.zone-3 .day.missing {
    background-color: var(--rate-miss);
}

.zone-1 .day.rate-1,
.zone-2 .day.rate-1,
.zone-3 .day.rate-1 {
    background-color: var(--rate-1);
}

.zone-1 .day.rate-2,
.zone-2 .day.rate-2,
.zone-3 .day.rate-2 {
    background-color: var(--rate-2);
}

.zone-1 .day.rate-3,
.zone-2 .day.rate-3,
.zone-3 .day.rate-3 {
    background-color: var(--rate-3);
}

.zone-1 .day.rate-4,
.zone-2 .day.rate-4,
.zone-3 .day.rate-4 {
    background-color: var(--rate-4);
}

.zone-1 .day.rate-5,
.zone-2 .day.rate-5,
.zone-3 .day.rate-5 {
    background-color: var(--rate-5);
}

.zone-1 .day.rate-6,
.zone-2 .day.rate-6,
.zone-3 .day.rate-6 {
    background-color: var(--rate-6);
}

.modal {
    display: none;
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    left: 20px;
    right: 20px;
    background: var(--modal-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text-color);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-border);
    z-index: 1000;
}

.modal h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--subtext);
}

.modal p {
    margin: 0;
    font-size: 16px;
}

.close-btn {
    position: absolute;
    top: 18px;
    right: 20px;
    cursor: pointer;
    font-size: 14px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--close-btn);
    color: var(--text-color);
}

/* SETTINGS */
.settings-block {
    margin-bottom: 25px;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
}

.settings-block h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
}

.theme-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.theme-btn {
    padding: 12px;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.theme-btn:hover {
    border-color: var(--primary);
    background: var(--rate-future);
}

.add-form {
    display: flex;
    gap: 8px;
}

.add-form input {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-color);
}

.week-selector {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.day-btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-color);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.day-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.archived-item {
    opacity: 0.6;
}

.archived-item .title {
    text-decoration: line-through;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--bg-color);
    justify-content: space-between;
}

.todo-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.todo-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.todo-item .del-btn {
    background: var(--rate-1);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
}