/* Notes Pop-out Panel Styles */

.notes-popout {
    position: fixed;
    z-index: 9999999999;
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 400px;
    min-height: 200px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    backdrop-filter: blur(10px);
}

/* Header - Draggable */
.notes-popout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #2196F3;
    color: #fff;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.notes-popout-header .header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.notes-popout-header .header-title .material-symbols-rounded {
    font-size: 24px;
    flex-shrink: 0;
}

.notes-popout-header .header-title h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-popout-header .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.notes-popout-header .btn-minimize,
.notes-popout-header .btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
}

.notes-popout-header .btn-minimize:hover,
.notes-popout-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.notes-popout-header .btn-minimize .material-symbols-rounded,
.notes-popout-header .btn-close .material-symbols-rounded {
    font-size: 18px;
}

/* Unit Navigation */
.notes-unit-nav {
    padding: 12px 18px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.notes-unit-nav .unit-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232196F3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 44px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.notes-unit-nav .unit-select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.notes-unit-nav .unit-select:hover {
    border-color: #90CAF9;
}

/* Section Jump Navigation */
.notes-unit-nav .section-jump-nav {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.notes-unit-nav .section-jump-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notes-unit-nav .section-jump-btn:hover {
    border-color: #90CAF9;
    color: #1976D2;
    background: #E3F2FD;
}

.notes-unit-nav .section-jump-btn.active {
    background: #2196F3;
    border-color: #2196F3;
    color: #fff;
}

/* Content Area */
.notes-popout-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
}

/* Custom Scrollbar */
.notes-popout-content::-webkit-scrollbar {
    width: 8px;
}

.notes-popout-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.notes-popout-content::-webkit-scrollbar-thumb {
    background: #90CAF9;
    border-radius: 4px;
}

.notes-popout-content::-webkit-scrollbar-thumb:hover {
    background: #64B5F6;
}

/* Resize Handle */
.notes-popout-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    cursor: se-resize;
    background: transparent;
    border-radius: 0 0 16px 0;
}

.notes-popout-resize::before {
    content: '';
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-right: 2px solid #BBDEFB;
    border-bottom: 2px solid #BBDEFB;
    border-radius: 0 0 2px 0;
    transition: border-color 0.2s ease;
}

.notes-popout-resize:hover::before {
    border-color: #2196F3;
}

/* Loading State */
.notes-popout .notes-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #64748b;
}

.notes-popout .notes-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: notesPopoutSpin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes notesPopoutSpin {
    to {
        transform: rotate(360deg);
    }
}

.notes-popout .notes-loading p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

/* Error State */
.notes-popout .notes-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
    text-align: center;
}

.notes-popout .notes-error .material-symbols-rounded {
    font-size: 56px;
    color: #f87171;
    margin-bottom: 16px;
}

.notes-popout .notes-error p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

/* No Template State */
.notes-popout .notes-no-template {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 60px 20px;
}

.notes-popout .notes-no-template .empty-state {
    text-align: center;
}

.notes-popout .notes-no-template .empty-icon {
    font-size: 72px;
    color: #BBDEFB;
    margin-bottom: 20px;
}

.notes-popout .notes-no-template .empty-title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 600;
    color: #475569;
}

.notes-popout .notes-no-template .empty-subtitle {
    margin: 0;
    font-size: 14px;
    color: #94a3b8;
    line-height: 1.6;
}

/* Form Styles */
.notes-popout .notes-form {
    padding: 0;
}

.notes-popout .save-indicator {
    position: sticky;
    top: 0;
    background: linear-gradient(90deg, #f0fdf4 0%, #dcfce7 100%);
    padding: 10px 18px;
    border-bottom: 1px solid #bbf7d0;
    font-size: 13px;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.notes-popout .save-indicator .status-saving {
    color: #1976D2;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.notes-popout .save-indicator .status-saved {
    color: #16a34a;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.notes-popout .save-indicator .material-symbols-rounded {
    font-size: 18px;
}

.notes-popout .save-indicator .material-symbols-rounded.spinning {
    animation: notesPopoutSpin 1s linear infinite;
}

.notes-popout .template-description {
    padding: 16px 20px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-bottom: 1px solid #bfdbfe;
    margin: 0;
}

.notes-popout .template-description p {
    margin: 0;
    font-size: 13px;
    color: #3b82f6;
    line-height: 1.6;
    font-weight: 500;
}

.notes-popout .form-sections {
    padding: 20px;
}

/* Simple fields layout (no sections) */
.notes-popout .notes-fields {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.notes-popout .form-section {
    margin-bottom: 28px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.notes-popout .form-section:hover {
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.05),
        0 2px 4px rgba(0, 0, 0, 0.1);
    border-color: #90CAF9;
}

.notes-popout .form-section:last-child {
    margin-bottom: 0;
}

/* Section Header - Collapsible */
.notes-popout .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 2px solid #e2e8f0;
    transition: border-color 0.2s ease;
}

.notes-popout .section-header:hover {
    border-color: #90CAF9;
}

.notes-popout .section-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.notes-popout .section-number {
    width: 28px;
    height: 28px;
    background: #2196F3;
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.notes-popout .section-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.notes-popout .section-toggle-btn {
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notes-popout .section-toggle-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

.notes-popout .section-toggle-btn .material-symbols-rounded {
    font-size: 20px;
}

.notes-popout .section-description {
    margin: 0 0 16px;
    font-size: 13px;
    color: #64748b;
    padding-left: 0;
    line-height: 1.5;
    font-style: italic;
}

.notes-popout .section-fields {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.notes-popout .form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notes-popout .field-label {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    line-height: 1.5;
    margin-bottom: 8px;
}

.notes-popout .field-label p {
    margin: 0 0 0.5em;
}

.notes-popout .field-label p:last-child {
    margin-bottom: 0;
}

.notes-popout .field-label ul,
.notes-popout .field-label ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.notes-popout .field-label a {
    color: #2196F3;
    text-decoration: underline;
}

/* Field input wrapper for mic button */
.notes-popout .field-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-popout .field-input-wrapper .field-input {
    flex: 1;
}

/* Field editor wrapper for mic button */
.notes-popout .field-editor-wrapper {
    position: relative;
}

.notes-popout .field-editor-wrapper .btn-mic-editor {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

/* Microphone button styles */
.notes-popout .btn-mic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notes-popout .btn-mic:hover {
    background: #e2e8f0;
    border-color: #2196F3;
    color: #2196F3;
}

.notes-popout .btn-mic.recording {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
    animation: mic-pulse 1.5s ease-in-out infinite;
}

.notes-popout .btn-mic .material-symbols-rounded {
    font-size: 18px;
}

@keyframes mic-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Table mic button */
.notes-popout .btn-mic-table {
    width: 32px;
    height: 32px;
}

.notes-popout .btn-mic-table .material-symbols-rounded {
    font-size: 16px;
}

.notes-popout .mic-col {
    width: 50px;
}

.notes-popout .mic-cell {
    text-align: center;
    vertical-align: middle;
    padding: 8px !important;
}

.notes-popout .field-input,
.notes-popout .field-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
    background: #fafbff;
}

.notes-popout .field-input:focus,
.notes-popout .field-textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background: #fff;
}

.notes-popout .field-input:hover,
.notes-popout .field-textarea:hover {
    border-color: #90CAF9;
}

.notes-popout .field-input::placeholder,
.notes-popout .field-textarea::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Disable copy/paste */
.notes-popout .no-copy-paste {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.notes-popout .field-textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

/* Froala Editor Styles */
.notes-popout .field-editor {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    background: #fafbff;
}

.notes-popout .field-editor:focus-within {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background: #fff;
}

.notes-popout .field-editor:hover {
    border-color: #90CAF9;
}

.notes-popout .field-editor .fr-box {
    border: none !important;
}

.notes-popout .field-editor .fr-toolbar {
    background: #f8fafc !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-radius: 8px 8px 0 0 !important;
    padding: 4px 8px !important;
}

.notes-popout .field-editor .fr-wrapper {
    border: none !important;
    background: transparent !important;
}

.notes-popout .field-editor .fr-element {
    padding: 12px 14px !important;
    font-size: 14px !important;
    min-height: 80px !important;
    background: transparent !important;
}

.notes-popout .field-editor .fr-element:focus {
    outline: none !important;
}

.notes-popout .field-editor .fr-placeholder {
    padding: 12px 14px !important;
    font-size: 14px !important;
    color: #94a3b8 !important;
    font-style: italic !important;
}

.notes-popout .field-editor .fr-second-toolbar {
    display: none !important;
}

.notes-popout .field-editor .fr-btn-grp {
    margin: 0 4px !important;
}

.notes-popout .field-editor .fr-command.fr-btn {
    margin: 2px !important;
    padding: 6px !important;
    border-radius: 6px !important;
}

.notes-popout .field-editor .fr-command.fr-btn:hover {
    background: #e2e8f0 !important;
}

.notes-popout .field-editor .fr-command.fr-btn.fr-active {
    background: #2196F3 !important;
    color: #fff !important;
}

/* Table Styles */
.notes-popout .form-table {
    margin-top: 20px;
}

.notes-popout .table-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-popout .table-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: #2196F3;
    border-radius: 2px;
}

.notes-popout .table-container {
    overflow-x: auto;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

.notes-popout .notes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.notes-popout .notes-table th,
.notes-popout .notes-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.notes-popout .notes-table th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.notes-popout .notes-table tr:last-child td {
    border-bottom: none;
}

.notes-popout .notes-table tr:hover td {
    background: #fafbff;
}

.notes-popout .table-cell-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    background: #f8fafc;
    transition: all 0.2s ease;
    box-sizing: border-box;
    line-height: 1.4;
}

.notes-popout .table-cell-input:focus {
    outline: none;
    border-color: #2196F3;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.notes-popout .table-cell-input:hover {
    background: #fff;
    border-color: #e2e8f0;
}

.notes-popout .table-cell-input::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Vocabulary Field Styles - Table Layout */
.notes-popout .field-vocab {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.notes-popout .vocab-terms {
    display: flex;
    flex-direction: column;
}

.notes-popout .vocab-term-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.notes-popout .vocab-term-row:last-child {
    border-bottom: none;
}

.notes-popout .vocab-term-row:hover {
    background: #f8fafc;
}

.notes-popout .vocab-term-word {
    flex: 0 0 140px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    padding: 14px 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-right: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    word-break: break-word;
}

.notes-popout .vocab-term-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-width: 0;
}

.notes-popout .vocab-term-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
    background: #fafbff;
    min-width: 0;
}

.notes-popout .vocab-term-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background: #fff;
}

.notes-popout .vocab-term-input:hover {
    border-color: #90CAF9;
}

.notes-popout .vocab-term-input::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Responsive */
@media (max-width: 500px) {
    .notes-popout {
        left: 10px !important;
        right: 10px !important;
        top: 10px !important;
        bottom: 10px !important;
        width: auto !important;
        height: auto !important;
        max-width: none;
        max-height: none;
        border-radius: 12px;
    }

    .notes-popout .form-sections {
        padding: 16px;
    }

    .notes-popout .form-section {
        padding: 16px;
    }

    .notes-popout .notes-table th,
    .notes-popout .notes-table td {
        padding: 10px;
    }

    .notes-popout .vocab-term-row {
        flex-direction: column;
    }

    .notes-popout .vocab-term-word {
        flex: none;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 10px 12px;
    }

    .notes-popout .vocab-term-input-wrapper {
        padding: 10px 12px;
    }
}
