/* ============================================================
   PHANTOM MSG — Notes Module Styles
   Modulo de notas personales con texto rico y checklist
   ============================================================ */

/* Color palette for notes (9 colors like ColorNote) */
:root {
    --note-color-0: #3a3f4b;
    --note-color-1: #e8c840;
    --note-color-2: #4a90d9;
    --note-color-3: #4caf50;
    --note-color-4: #e77c9e;
    --note-color-5: #9c6dcd;
    --note-color-6: #f09040;
    --note-color-7: #78838f;
    --note-color-8: #e05252;
}

/* Note card color classes — background with transparency */
.note-c0 { --card-bg: rgba(58,63,75,0.25); --card-border: rgba(58,63,75,0.5); }
.note-c1 { --card-bg: rgba(232,200,64,0.15); --card-border: rgba(232,200,64,0.4); }
.note-c2 { --card-bg: rgba(74,144,217,0.15); --card-border: rgba(74,144,217,0.4); }
.note-c3 { --card-bg: rgba(76,175,80,0.15); --card-border: rgba(76,175,80,0.4); }
.note-c4 { --card-bg: rgba(231,124,158,0.15); --card-border: rgba(231,124,158,0.4); }
.note-c5 { --card-bg: rgba(156,109,205,0.15); --card-border: rgba(156,109,205,0.4); }
.note-c6 { --card-bg: rgba(240,144,64,0.15); --card-border: rgba(240,144,64,0.4); }
.note-c7 { --card-bg: rgba(120,131,143,0.15); --card-border: rgba(120,131,143,0.4); }
.note-c8 { --card-bg: rgba(224,82,82,0.15); --card-border: rgba(224,82,82,0.4); }

/* ---- NOTES CONTAINER ---- */
#panel-notes.tool-panel {
    max-width: 100%;
    padding: 16px 24px;
}

.notes-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 12px;
    overflow-y: auto;
}

/* ---- HEADER ---- */
.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.notes-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #F0F4F8);
    margin: 0;
}

.notes-header-actions {
    display: flex;
    gap: 8px;
}

.notes-view-toggle,
.notes-btn-new {
    background: var(--bg-card, #151D30);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    color: var(--text-secondary, #8B9BB4);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.notes-view-toggle:hover,
.notes-btn-new:hover {
    background: var(--primary-400, #2DD4BF);
    color: #fff;
}

/* ---- SEARCH ---- */
.notes-search-wrap {
    position: relative;
    flex-shrink: 0;
}

.notes-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #8B9BB4);
    pointer-events: none;
}

.notes-search-input {
    width: 100%;
    background: var(--bg-card, #151D30);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: 8px;
    padding: 8px 12px 8px 36px;
    color: var(--text-primary, #F0F4F8);
    font-size: 0.875rem;
    outline: none;
    box-sizing: border-box;
}

.notes-search-input:focus {
    border-color: var(--primary-400, #2DD4BF);
}

/* ---- COLOR FILTER ---- */
.notes-color-filter {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.notes-color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--dot-color, var(--bg-card));
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}

.notes-color-dot:hover {
    transform: scale(1.15);
}

.notes-color-dot.active {
    border-color: var(--primary-400, #2DD4BF);
    transform: scale(1.15);
}

.notes-color-all {
    background: conic-gradient(
        var(--note-color-1), var(--note-color-2), var(--note-color-3),
        var(--note-color-4), var(--note-color-5), var(--note-color-6),
        var(--note-color-8), var(--note-color-1)
    );
}

/* ---- GRID VIEW ---- */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    align-content: start;
}

/* ---- LIST VIEW ---- */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
}

.notes-list .note-card {
    min-height: unset;
    max-height: 64px;
}

.notes-list .note-card .note-card-body {
    -webkit-line-clamp: 1;
    max-height: 1.4em;
}

/* ---- NOTE CARD ---- */
.note-card {
    background: var(--card-bg, rgba(255,255,255,0.06));
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
    max-height: 180px;
    overflow: hidden;
}

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

.note-card:active {
    transform: scale(0.98);
}

.note-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.note-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary, #F0F4F8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.note-card-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.note-card-pin, .note-card-lock, .note-card-type {
    color: var(--text-secondary, #8B9BB4);
    display: flex;
}

.note-card-body {
    font-size: 0.78rem;
    color: var(--text-secondary, #8B9BB4);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    white-space: pre-wrap;
    word-break: break-word;
}

.note-card-locked-text {
    font-style: italic;
    opacity: 0.6;
}

.note-card-footer {
    font-size: 0.7rem;
    color: var(--text-secondary, #666);
    margin-top: auto;
}

/* ---- EMPTY STATE ---- */
.notes-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-secondary, #8B9BB4);
}

.notes-empty p {
    margin: 0;
    font-size: 0.9rem;
}

.notes-empty-actions {
    display: flex;
    gap: 10px;
}

.notes-empty-btn {
    background: var(--primary-400, #2DD4BF);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.notes-empty-btn:hover {
    opacity: 0.85;
}

/* ---- FAB (Floating Action Button for checklist) ---- */
.notes-fab-checklist {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--primary-400, #2DD4BF);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(45,212,191,0.4);
    transition: transform 0.15s;
    z-index: 100;
}

.notes-fab-checklist:hover {
    transform: scale(1.08);
}

/* ---- NOTE EDITOR ---- */
.note-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-elevated, #1A2440);
}

.note-editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
    flex-shrink: 0;
}

.note-editor-back {
    background: none;
    border: none;
    color: var(--text-secondary, #8B9BB4);
    cursor: pointer;
    padding: 4px;
    display: flex;
    border-radius: 6px;
    transition: color 0.2s;
}

.note-editor-back:hover {
    color: var(--primary-400, #2DD4BF);
}

.note-editor-title {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary, #F0F4F8);
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    padding: 4px 0;
}

.note-editor-title::placeholder {
    color: var(--text-secondary, #666);
}

.note-editor-actions {
    display: flex;
    gap: 4px;
}

.note-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #8B9BB4);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    transition: color 0.2s, background 0.2s;
}

.note-action-btn:hover {
    color: var(--text-primary, #F0F4F8);
    background: rgba(255,255,255,0.08);
}

.note-action-btn.active {
    color: var(--primary-400, #2DD4BF);
}

.note-action-delete:hover {
    color: #e05252;
}

/* ---- EDITOR COLOR PICKER ---- */
.note-editor-colors {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}

.note-ecolor {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--dot-color);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s, border-color 0.12s;
}

.note-ecolor:hover {
    transform: scale(1.2);
}

.note-ecolor.active {
    border-color: #fff;
    transform: scale(1.2);
}

/* ---- RICH TEXT TOOLBAR ---- */
.note-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
    flex-shrink: 0;
    flex-wrap: wrap;
}

.note-toolbar button {
    background: none;
    border: none;
    color: var(--text-secondary, #8B9BB4);
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    transition: background 0.15s, color 0.15s;
}

.note-toolbar button:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary, #F0F4F8);
}

.note-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border, rgba(255,255,255,0.06));
    margin: 0 4px;
}

.note-tb-hilite {
    color: #ffe040 !important;
}

/* ---- CONTENT AREA ---- */
.note-content {
    flex: 1;
    padding: 12px 16px;
    color: var(--text-primary, #F0F4F8);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-y: auto;
    outline: none;
    word-break: break-word;
}

.note-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-secondary, #666);
    pointer-events: none;
}

.note-content ul, .note-content ol {
    margin: 4px 0;
    padding-left: 24px;
}

.note-content mark {
    background: rgba(255,235,59,0.4);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

/* ---- CHECKLIST ---- */
.note-checklist {
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
}

.note-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.04));
}

.note-check-cb {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-400, #2DD4BF);
    cursor: pointer;
    flex-shrink: 0;
}

.note-check-text {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary, #F0F4F8);
    font-size: 0.88rem;
    outline: none;
    padding: 6px 0;
}

.note-check-text.checked {
    text-decoration: line-through;
    opacity: 0.5;
}

.note-check-text::placeholder {
    color: var(--text-secondary, #555);
}

.note-check-del {
    background: none;
    border: none;
    color: var(--text-secondary, #555);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.note-check-item:hover .note-check-del {
    opacity: 1;
}

.note-check-del:hover {
    color: #e05252;
}

.note-checklist-add {
    padding: 8px 0;
}

.note-checklist-add button {
    background: none;
    border: 1px dashed var(--border, rgba(255,255,255,0.06));
    color: var(--text-secondary, #8B9BB4);
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    width: 100%;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s;
}

.note-checklist-add button:hover {
    border-color: var(--primary-400, #2DD4BF);
    color: var(--primary-400, #2DD4BF);
}

/* ---- SAVE INDICATOR ---- */
.note-save-indicator {
    padding: 6px 12px;
    font-size: 0.72rem;
    color: var(--text-secondary, #666);
    text-align: right;
    flex-shrink: 0;
}

/* ---- MODALS ---- */
.note-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.note-modal {
    background: var(--bg-elevated, #1A2440);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 24px;
    width: min(340px, 90vw);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.note-modal h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: var(--text-primary, #F0F4F8);
}

.note-modal p {
    margin: 0 0 16px;
    font-size: 0.85rem;
    color: var(--text-secondary, #8B9BB4);
}

.note-modal-input {
    width: 100%;
    background: var(--bg-card, #151D30);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary, #F0F4F8);
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}

.note-modal-input:focus {
    border-color: var(--primary-400, #2DD4BF);
}

.note-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.note-modal-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    transition: opacity 0.2s;
}

.note-modal-cancel {
    background: var(--bg-card, #151D30);
    color: var(--text-secondary, #8B9BB4);
}

.note-modal-ok {
    background: var(--primary-400, #2DD4BF);
    color: #fff;
}

.note-modal-btn:hover {
    opacity: 0.85;
}

/* ---- HIDDEN NOTES (accessed via secret code in search) ---- */
.note-card-hidden {
    color: var(--text-secondary, #8B9BB4);
    display: flex;
}

.notes-secret-btn {
    background: var(--bg-card, #151D30);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    color: var(--text-secondary, #8B9BB4);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.notes-secret-btn:hover {
    background: var(--primary-400, #2DD4BF);
    color: #fff;
}

.note-modal-hint {
    font-size: 0.75rem;
    color: var(--text-secondary, #8B9BB4);
    margin-top: 8px;
    font-style: italic;
}

/* ---- INVISIBLE INK — Hold to reveal ---- */
.note-ink-blur .note-card-body,
.note-ink-blur .note-card-title {
    filter: blur(8px);
    user-select: none;
    -webkit-user-select: none;
    transition: filter 0.3s ease;
}

.note-ink-blur.ink-revealed .note-card-body,
.note-ink-blur.ink-revealed .note-card-title {
    filter: blur(0);
}

.note-ink-blur::after {
    content: 'Manten presionado para ver';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.68rem;
    color: var(--text-secondary, #8B9BB4);
    pointer-events: none;
    opacity: 0.8;
    white-space: nowrap;
    transition: opacity 0.3s;
}

.note-ink-blur.ink-revealed::after {
    opacity: 0;
}

.note-ink-blur {
    position: relative;
}

/* ---- SELF-DESTRUCT TIMER ---- */
.note-timer-badge {
    font-size: 0.6rem;
    font-weight: 700;
    color: #e05252;
    background: rgba(224,82,82,0.15);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    display: inline-block;
    vertical-align: middle;
}

.note-card-timer {
    font-size: 0.65rem;
    font-weight: 600;
    color: #e05252;
    background: rgba(224,82,82,0.12);
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 6px;
    display: inline-block;
}

.note-card-timer-expired {
    opacity: 0.5;
}

.note-ttl-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.note-ttl-btn {
    background: var(--bg-card, #151D30);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    color: var(--text-primary, #F0F4F8);
    border-radius: 8px;
    padding: 10px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-align: center;
}

.note-ttl-btn:hover {
    background: rgba(224,82,82,0.15);
    border-color: rgba(224,82,82,0.4);
    color: #e05252;
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {
    .notes-container {
        padding: 12px;
    }
    
    .notes-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }
    
    .note-card {
        min-height: 60px;
        padding: 10px;
    }

    /* Panel padding override for notes on mobile */
    #panel-notes {
        padding: 0 !important;
        padding-bottom: 70px !important;
    }

    /* FAB must sit above the mobile bottom nav (56px + safe-area + spacing) */
    .notes-fab-checklist {
        bottom: 76px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }
}
