/* ============================================================
   Daily Notes (Dashboard Module)
============================================================ */

/* ============================================================
   Container
============================================================ */

.daily-notes {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

/* ============================================================
   Header
============================================================ */

.daily-notes__header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-bottom: 14px;
}

.daily-notes__title {
    margin: 0;
    color: var(--color-text);
    font-size: 17px;
    font-weight: 600;
}

/* ============================================================
   Content Area
============================================================ */

.daily-notes__content {
    min-width: 0;
    min-height: 0;
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

/* ============================================================
   Notebook Button (Closed View)
============================================================ */

.daily-notebook {
    width: min(78%, 250px);
    height: min(78%, 190px);
    position: relative;
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    perspective: 1000px;
    transition: transform 220ms ease;
}

.daily-notebook:hover {
    transform: translateY(-5px) rotate(-1deg);
}

.daily-notebook:active {
    transform: translateY(-1px) scale(0.98);
}

/* Book */
.daily-notebook__book {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    border-radius: 5px 14px 14px 5px;
    box-shadow: var(--shadow-md), inset 3px 0 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    transition: box-shadow 220ms ease, transform 220ms ease;
}

.daily-notebook:hover .daily-notebook__book {
    box-shadow: var(--shadow-lg), inset 3px 0 0 rgba(255, 255, 255, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}

/* Spine */
.daily-notebook__spine {
    width: 9px;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.1));
    border-radius: 0 14px 14px 0;
}

/* Inner Content */
.daily-notebook__content {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #ffffff;
}

.daily-notebook__icon {
    display: block;
    font-size: 38px;
    line-height: 1;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.18));
    transition: transform 220ms ease;
}

.daily-notebook:hover .daily-notebook__icon {
    transform: rotate(-5deg) scale(1.08);
}

.daily-notebook__name {
    font-size: 14px;
    font-weight: 600;
}

.daily-notebook__date {
    font-size: 10px;
    opacity: 0.72;
}

/* Spiral */
.daily-notebook__spiral {
    position: absolute;
    top: -7px;
    right: 22px;
    left: 22px;
    height: 24px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
    pointer-events: none;
}

.daily-notebook__spiral span {
    width: 12px;
    height: 25px;
    display: block;
    border: 2px solid var(--color-border-strong);
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
}

/* ============================================================
   Status Pill
============================================================ */

.daily-notebook__status {
    position: absolute;
    right: 50%;
    bottom: -6px;
    transform: translateX(50%);
    z-index: 20;
    pointer-events: none;
}

.daily-notebook__message {
    display: block;
    padding: 5px 10px;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 10px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

/* Has Note State */
.daily-notebook[data-note-exists="true"] .daily-notebook__book {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    box-shadow: var(--shadow-md), inset 3px 0 0 rgba(255, 255, 255, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}

.daily-notebook[data-note-exists="true"] .daily-notebook__message {
    color: var(--color-primary-light);
    background: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-primary) 30%, var(--color-border));
    font-weight: 600;
}

/* ============================================================
   Daily Note Modal
============================================================ */

.daily-note-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 2000;
    perspective: 1400px;
    transition: opacity 250ms ease, visibility 250ms ease;
}

.daily-note-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Overlay */
.daily-note-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

/* Book */
.daily-note-modal__book {
    width: min(900px, 100%);
    height: min(620px, calc(100vh - 48px));
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 0.78fr 1.45fr;
    overflow: hidden;
    border-radius: 8px 18px 18px 8px;
    box-shadow: var(--shadow-lg), 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: rotateY(-18deg) scale(0.88) translateY(20px);
    transform-origin: center;
    transition: transform 500ms cubic-bezier(.22, .8, .24, 1);
}

.daily-note-modal.is-open .daily-note-modal__book {
    transform: rotateY(0) scale(1) translateY(0);
}

/* ============================================================
   Modal Cover
============================================================ */

.daily-note-modal__cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    overflow: hidden;
    background: linear-gradient(145deg, var(--color-primary), var(--color-primary-dark));
}

.daily-note-modal__cover::after {
    content: "";
    position: absolute;
    inset: 20px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 5px;
}

.daily-note-modal__cover-spiral {
    position: absolute;
    top: 20px;
    right: -4px;
    bottom: 20px;
    width: 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    z-index: 3;
}

.daily-note-modal__cover-spiral span {
    width: 22px;
    height: 32px;
    border: 2px solid var(--color-border-strong);
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
}

.daily-note-modal__cover-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: #ffffff;
    text-align: center;
}

.daily-note-modal__cover-icon {
    font-size: 58px;
    filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.18));
}

.daily-note-modal__cover-title {
    font-size: 19px;
    font-weight: 700;
}

.daily-note-modal__cover-date {
    font-size: 12px;
    opacity: 0.68;
}

/* ============================================================
   Modal Page
============================================================ */

.daily-note-modal__page {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 30px 34px;
    background: var(--color-surface);
}

.daily-note-modal__header {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.daily-note-modal__eyebrow {
    color: var(--color-primary-light);
    font-size: 11px;
    font-weight: 600;
}

.daily-note-modal__title {
    margin: 5px 0 0;
    color: var(--color-text);
    font-size: 21px;
    font-weight: 700;
}

.daily-note-modal__close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-secondary);
    background: var(--color-surface-elevated);
    font-family: inherit;
    font-size: 22px;
    cursor: pointer;
    transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.daily-note-modal__close:hover {
    color: var(--color-primary-light);
    background: var(--color-surface-hover);
    transform: rotate(5deg);
}

/* ============================================================
   Editor
============================================================ */

.daily-note-modal__editor {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface-elevated);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.daily-note-modal__lines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 31px,
        color-mix(in srgb, var(--color-primary) 15%, transparent) 32px
    );
    pointer-events: none;
}

.daily-note-modal__textarea {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
    resize: none;
    padding: 16px 20px;
    border: none;
    outline: none;
    color: var(--color-text);
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 32px;
    direction: rtl;
    scrollbar-width: thin;
}

.daily-note-modal__textarea::placeholder {
    color: var(--color-text-muted);
}

/* ============================================================
   Modal Footer
============================================================ */

.daily-note-modal__footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-top: 18px;
}

.daily-note-modal__counter {
    color: var(--color-text-secondary);
    font-size: 11px;
}

.daily-note-modal__actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

.daily-note-modal__cancel,
.daily-note-modal__save {
    height: 42px;
    padding-inline: 18px;
    border-radius: 11px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.daily-note-modal__cancel {
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    background: var(--color-surface-elevated);
}

.daily-note-modal__cancel:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.daily-note-modal__save {
    border: none;
    color: #ffffff;
    background: var(--color-primary);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

.daily-note-modal__save:hover {
    background: var(--color-primary-light);
    transform: translateY(-1px);
    box-shadow: 0 7px 16px color-mix(in srgb, var(--color-primary) 35%, transparent);
}

/* ============================================================
   Dark Theme Support
============================================================ */

:root[data-theme="dark"] .daily-notebook__book {
    background: linear-gradient(135deg, #5fb3cc, #3d8ea6);
}

:root[data-theme="dark"] .daily-note-modal__cover {
    background: linear-gradient(145deg, #5fb3cc, #3d8ea6);
}

:root[data-theme="dark"] .daily-note-modal__lines {
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 31px,
        rgba(95, 179, 204, 0.12) 32px
    );
}

:root[data-theme="dark"] .daily-notebook[data-note-exists="true"] .daily-notebook__book {
    background: linear-gradient(135deg, #5fb3cc, #3d8ea6);
}

:root[data-theme="dark"] .daily-note-modal__page {
    background: #1a2629;
}

:root[data-theme="dark"] .daily-note-modal__editor {
    background: #1a2629;
    border-color: rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .daily-note-modal__close {
    background: #1a2629;
    border-color: rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .daily-note-modal__close:hover {
    background: #203035;
}

:root[data-theme="dark"] .daily-note-modal__save {
    background: #5fb3cc;
}

:root[data-theme="dark"] .daily-note-modal__save:hover {
    background: #6fc2db;
}

/* ============================================================
   🔥 Dark Theme - Status Pill Fix
============================================================ */

:root[data-theme="dark"] .daily-notebook__message {
    color: #c8d6d9;
    background: #1a2629;
    border-color: #2a3a3e;
}

:root[data-theme="dark"] .daily-notebook[data-note-exists="true"] .daily-notebook__message {
    color: #7cc4d8;
    background: rgba(95, 179, 204, 0.12);
    border-color: rgba(95, 179, 204, 0.30);
}

/* ============================================================
   Responsive Design
============================================================ */

@media (max-width: 760px) {
    .daily-note-modal {
        padding: 14px;
    }

    .daily-note-modal__book {
        height: min(680px, calc(100vh - 28px));
        grid-template-columns: 1fr;
        grid-template-rows: 180px 1fr;
        border-radius: 16px;
    }

    .daily-note-modal__cover {
        padding: 20px;
    }

    .daily-note-modal__cover-icon {
        font-size: 40px;
    }

    .daily-note-modal__cover-title {
        font-size: 16px;
    }

    .daily-note-modal__cover-spiral {
        top: auto;
        right: 20px;
        left: 20px;
        bottom: -5px;
        width: auto;
        height: 22px;
        flex-direction: row;
    }

    .daily-note-modal__cover-spiral span {
        width: 28px;
        height: 20px;
    }

    .daily-note-modal__page {
        padding: 22px;
    }
}

@media (max-width: 480px) {
    .daily-notebook {
        width: 78%;
        height: 180px;
    }

    .daily-note-modal__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .daily-note-modal__actions {
        width: 100%;
    }

    .daily-note-modal__cancel,
    .daily-note-modal__save {
        flex: 1;
    }
}