/* ============================================
   NOTE TAKING FEATURE STYLES
   ============================================ */

/* ─── Mobile Note Toggle Button ────────────────────── */
/* .note-toggle {
    position: fixed;
    right: 10px;
    bottom: 80px;
    border-radius: 100px;
    transform: translateY(50%);
    background-color: var(--accent-maroon);
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-md);
    padding: 20px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    cursor: pointer;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
    writing-mode: vertical-rl;
    text-orientation: mixed;
} */
.note-toggle {
    position: fixed;
    bottom: 70px;
    /* left: 20px; */
    right: 20px;
    background-color: var(--accent-maroon);
    color: var(--text-white);
    padding: 20px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-maroon);
    transition: all var(--transition-fast);
}

.note-toggle:hover {
    background-color: var(--maroon-hover);
    padding-right: var(--spacing-lg);
}

.note-toggle i {
    font-size: var(--font-lg);
    writing-mode: horizontal-tb;
}

/* ─── Desktop Note Button ──────────────────────────── */
.note-button-desktop,
.note-toggle {
    position: fixed;
    bottom: 70px;
    /* left: 20px; */
    right: 20px;
    background-color: var(--accent-maroon);
    color: var(--text-white);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    cursor: pointer;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-maroon);
    transition: all var(--transition-fast);
}

.note-button-desktop:hover {
    background-color: var(--maroon-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.note-button-desktop i {
    font-size: var(--font-lg);
}

.note-button-desktop span {
    font-size: var(--font-md);
    font-weight: var(--font-semibold);
}

/* ─── Note Modal ──────────────────────────────────── */
.note-modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.note-modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    /* Important for flex child with overflow */
}

/* ─── Merged Editor / Preview Section ───────────────── */
.note-merged-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Take up available vertical space */
    min-height: 250px;
    margin-bottom: var(--spacing-md);
}

.note-preview-wrapper,
.note-editor-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.note-textarea {
    width: 100%;
    flex: 1;
    min-height: 250px;
    padding: var(--spacing-md);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-md);
    line-height: 1.6;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.note-textarea:focus {
    outline: none;
    border-color: var(--accent-maroon);
}

/* Force black text on white background for PDF printing */
.note-preview-content.printing-pdf {
    color: #000000 !important;
    background-color: #ffffff !important;
    border-color: transparent !important;
}

.note-preview-content.printing-pdf * {
    color: #000000 !important;
    background-color: transparent !important;
    border-color: transparent !important;
    text-shadow: none !important;
}

.note-textarea::placeholder {
    color: var(--text-light);
}

.note-preview-content {
    flex: 1;
    padding: var(--spacing-md);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    background-color: var(--bg-lighter);
    min-height: 250px;
    font-size: var(--font-md);
    line-height: 1.6;
    color: var(--text-dark);
    cursor: text;
    /* Indicate it can be clicked to type */
    overflow-y: auto;
}

.note-preview-content:hover {
    border-color: rgba(128, 0, 0, 0.3);
    /* subtle hint that it's interactive */
}

.note-preview-content:focus {
    outline: none;
    border-color: var(--accent-maroon);
}

.note-preview-content .note-empty-message {
    color: var(--text-light);
    font-style: italic;
    margin: 0;
}

.note-preview-content a {
    color: var(--accent-maroon);
    text-decoration: underline;
    position: relative;
    z-index: 2;
    /* Ensure links are clickable above the wrapper */
}

.note-preview-content a:hover {
    color: var(--maroon-hover);
}

.note-preview-content strong {
    font-weight: var(--font-bold);
}

.note-preview-content em {
    font-style: italic;
}

.note-preview-content code.inline-code {
    background-color: var(--bg-dark);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.note-preview-content pre {
    background-color: var(--bg-dark);
    color: var(--text-dark);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    overflow-x: auto;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--border-medium);
}

.note-preview-content pre code.inline-code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-family: inherit;
    font-size: inherit;
}

/* ─── Upload Sites Section ────────────────────────── */
.note-upload-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.note-upload-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.upload-instruction {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    font-size: var(--font-xs);
    color: var(--text-medium);
    margin: 0;
    line-height: 1.4;
    padding: var(--spacing-sm);
    background-color: var(--bg-lighter);
    border-radius: var(--radius-sm);
}

.upload-instruction i {
    color: var(--info);
    margin-top: 2px;
    flex-shrink: 0;
}

/* ─── Fallback & Helpers ──────────────────────────── */
.note-fileio-fallback {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    font-size: var(--font-sm);
    color: var(--text-dark);
    margin-top: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: #fff3cd;
    /* Warning yellowish */
    border-left: 4px solid #ffc107;
    border-radius: var(--radius-sm);
}

.note-fileio-fallback i {
    color: #ffc107;
    margin-top: 2px;
}

.note-fileio-fallback a {
    color: #d39e00;
    font-weight: bold;
    text-decoration: underline;
}

.note-download-helper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-sm);
    color: var(--text-dark);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: #d4edda;
    /* Success greenish */
    border-left: 4px solid #28a745;
    border-radius: var(--radius-sm);
    margin-top: var(--spacing-sm);
    animation: fadeIn 0.3s ease;
}

.note-download-helper i {
    color: #28a745;
}

.note-download-helper a {
    color: #155724;
    font-weight: bold;
    text-decoration: underline;
}

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

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

/* ─── Responsive Behavior ─────────────────────────── */
/* Mobile: Full screen modal */
@media (max-width: 768px) {
    .note-modal-content {
        width: 100%;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        margin: 0;
    }

    .note-textarea {
        min-height: 150px;
    }

    .note-preview-content {
        min-height: 100px;
    }

    /* Responsive Footer for Note Modal */
    #note-modal .modal-footer {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--spacing-sm);
        padding: var(--spacing-md);
    }

    #note-modal .modal-footer .btn {
        flex: 1 1 40%;
        /* Allow buttons to take ~half width and wrap */
        min-width: 100px;
        padding: var(--spacing-sm);
        font-size: var(--font-sm);
    }
}

/* Desktop: Centered popup */
@media (min-width: 769px) {
    .note-modal-content {
        max-width: 800px;
        max-height: 80vh;
        border-radius: var(--radius-lg);
    }
}

/* ─── Accessibility ───────────────────────────────── */
.note-toggle:focus,
.note-button-desktop:focus {
    outline: 2px solid var(--accent-maroon);
    outline-offset: 2px;
}

.note-textarea:focus {
    box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.1);
}

/* ─── Visibility Utilities ────────────────────────── */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
        /* Assuming flex for buttons */
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: flex !important;
        /* Assuming flex for buttons */
    }
}

/* Dark Mode Overrides */
body.dark-mode .note-textarea {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-medium);
}

body.dark-mode .note-textarea::placeholder {
    color: var(--text-light);
}

body.dark-mode .note-preview h3 {
    color: var(--text-dark);
}

body.dark-mode .note-preview-content {
    background-color: var(--bg-lighter);
    border-color: var(--border-medium);
    color: var(--text-dark);
}

body.dark-mode .upload-instruction {
    background-color: var(--bg-lighter);
    color: var(--text-medium);
}

body.dark-mode .note-preview-content a {
    color: var(--description-link-color, var(--link-blue));
}