/* ===============================================================
   ToolDuck — Online Group Notes Stylesheet
   Seamless integration with ToolDuck dark developer-tool aesthetic
   ============================================================== */

.group-notes-workspace {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    min-height: 520px;
    display: flex;
    flex-direction: column;
}

/* ---------------------------------------------------------------
   Cards (Create, Password, Expired)
   --------------------------------------------------------------- */
.note-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: clamp(1.5rem, 4vw, 2.75rem);
    text-align: center;
    position: relative;
    overflow: hidden;
    margin: 1rem auto;
    width: 100%;
    max-width: 780px;
}

.note-card__header {
    margin-bottom: 2rem;
}

.note-card__icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.note-card__icon--ended {
    background: #fef2f2;
    color: #ef4444;
}

html[data-theme="dark"] .note-card__icon--ended {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.note-card h2 {
    font-size: clamp(1.4rem, 2.5vw, 1.85rem);
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.note-card__desc {
    color: var(--ink-3);
    font-size: 1rem;
    line-height: 1.55;
    max-width: 600px;
    margin: 0 auto;
}

/* ---------------------------------------------------------------
   Form Layout & Input Controls
   --------------------------------------------------------------- */
.note-form {
    max-width: 580px;
    margin: 0 auto;
    text-align: left;
}

.form-group {
    margin-bottom: 1.35rem;
    text-align: left;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.form-label {
    display: block;
    width: 100%;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 0.45rem;
    text-align: left;
}

.form-optional {
    font-weight: 400;
    color: var(--ink-4);
    font-size: 0.82rem;
    margin-left: 0.35rem;
}

.form-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.8rem 1rem;
    font-size: 0.98rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.form-input:focus {
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' 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 0.9rem center;
    background-size: 14px;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-hint {
    display: block;
    font-size: 0.82rem;
    color: var(--ink-3);
    margin: 0.4rem 0 0;
    line-height: 1.4;
}

.form-hint--error {
    color: #ef4444;
    font-weight: 500;
}

.note-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 0;
}

@media (max-width: 580px) {
    .note-form__row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

.note-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.75rem;
}

.note-btn-submit {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    padding: 0.85rem 1.5rem;
    font-size: 1.05rem;
}

.note-card__security-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border);
    text-align: left;
}

.note-security-item {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
}

.note-security-icon {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--brand);
}

.note-security-item strong {
    display: block;
    font-size: 0.86rem;
    color: var(--ink-2);
    margin-bottom: 2px;
}

.note-security-item span {
    font-size: 0.78rem;
    color: var(--ink-3);
    line-height: 1.35;
}

/* ---------------------------------------------------------------
   Collaborative Editor Screen
   --------------------------------------------------------------- */
.note-editor-screen {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-height: 680px;
    height: 78vh;
    max-height: 880px;
    overflow: hidden;
    position: relative;
}

/* Editor Header */
.note-editor-topbar {
    padding: 0.65rem 1.25rem;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.note-title-wrap {
    flex: 1 1 220px;
}

.note-title-input {
    width: 100%;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.5rem;
    outline: none;
    letter-spacing: -0.01em;
    transition: border-color .18s ease, background-color .18s ease;
}

.note-title-input:hover {
    background: var(--surface);
    border-color: var(--border);
}

.note-title-input:focus {
    background: var(--surface);
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
}

.note-status-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.82rem;
}

.note-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink-2);
    font-weight: 500;
}

.note-sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    transition: background-color .2s ease;
}

.note-sync-dot--saving {
    background: #f59e0b;
    animation: anonPulse 1s infinite;
}

.note-sync-dot--error {
    background: #ef4444;
}

.note-online-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.note-expiry-badge {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--ink-3);
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.note-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---------------------------------------------------------------
   Formatting UI Toolbar / Pane
   --------------------------------------------------------------- */
.note-format-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 0.4rem;
    padding: 0.45rem 1rem;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    user-select: none;
}

.note-format-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.note-fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.4rem;
    font-size: 0.84rem;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.note-fmt-btn:hover {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: var(--brand-border);
}

.note-fmt-btn:active {
    transform: scale(0.96);
}

.note-fmt-btn--text {
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0 0.45rem;
}

.note-fmt-hl {
    background: #fef08a;
    color: #854d0e;
    padding: 0 3px;
    border-radius: 2px;
    font-weight: 700;
}

html[data-theme="dark"] .note-fmt-hl {
    background: #854d0e;
    color: #fef08a;
}

.note-fmt-divider {
    width: 1px;
    height: 18px;
    background: var(--border-strong);
    margin: 0 0.35rem;
    opacity: 0.6;
}

/* View Mode Pills (Edit / Split / Preview) */
.note-format-group--modes {
    margin-left: auto;
}

.note-mode-pills {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}

.note-mode-btn {
    padding: 0.22rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    transition: all .15s ease;
}

.note-mode-btn:hover {
    color: var(--ink);
}

.note-mode-btn.is-active {
    background: var(--brand);
    color: #ffffff;
    font-weight: 600;
}

/* ---------------------------------------------------------------
   Readonly Banner
   --------------------------------------------------------------- */
.note-readonly-banner {
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    padding: 0.45rem 1.25rem;
    font-size: 0.85rem;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

html[data-theme="dark"] .note-readonly-banner {
    background: rgba(30, 64, 175, 0.2);
    border-color: rgba(30, 64, 175, 0.4);
    color: #93c5fd;
}

.note-readonly-icon {
    flex-shrink: 0;
}

/* ---------------------------------------------------------------
   Workspace Body (Edit, Split, Preview Modes)
   --------------------------------------------------------------- */
.note-workspace-body {
    flex: 1;
    position: relative;
    background: var(--bg);
    display: flex;
    overflow: hidden;
}

.note-editor-pane {
    flex: 1;
    height: 100%;
    position: relative;
    display: flex;
}

.note-textarea {
    width: 100%;
    height: 100%;
    padding: 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--ink);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    white-space: pre-wrap;
    word-break: break-word;
}

.note-textarea:disabled {
    opacity: 0.85;
    cursor: default;
}

/* Preview Pane */
.note-preview-pane {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 1.25rem 1.75rem;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.note-preview-content {
    color: var(--ink);
    font-size: 1rem;
    line-height: 1.7;
    word-break: break-word;
}

.note-preview-content h1,
.note-preview-content h2,
.note-preview-content h3,
.note-preview-content h4 {
    color: var(--ink);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.note-preview-content h1 { font-size: 1.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
.note-preview-content h2 { font-size: 1.35rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
.note-preview-content h3 { font-size: 1.15rem; }
.note-preview-content h4 { font-size: 1.02rem; }

.note-preview-content p {
    margin: 0.5rem 0 0.85rem;
}

.note-preview-content ul,
.note-preview-content ol {
    margin: 0.5rem 0 0.85rem 1.5rem;
    padding: 0;
}

.note-preview-content li {
    margin-bottom: 0.25rem;
}

.note-preview-content blockquote {
    margin: 0.85rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--brand);
    background: var(--bg-soft);
    color: var(--ink-2);
    border-radius: 0 4px 4px 0;
}

.note-preview-content pre {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0.85rem 0;
}

.note-preview-content code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--bg-muted);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.note-preview-content pre code {
    background: transparent;
    padding: 0;
    border: none;
}

.note-preview-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.note-preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.92rem;
}

.note-preview-content th,
.note-preview-content td {
    border: 1px solid var(--border);
    padding: 0.55rem 0.85rem;
    text-align: left;
}

.note-preview-content th {
    background: var(--bg-soft);
    font-weight: 600;
}

.note-preview-content input[type="checkbox"] {
    margin-right: 0.45rem;
    vertical-align: middle;
}

/* Mode-dependent layouts */
.note-workspace-body[data-mode="edit"] .note-editor-pane { display: flex; width: 100%; }
.note-workspace-body[data-mode="edit"] .note-preview-pane { display: none; }

.note-workspace-body[data-mode="preview"] .note-editor-pane { display: none; }
.note-workspace-body[data-mode="preview"] .note-preview-pane { display: block; width: 100%; border-left: none; }

.note-workspace-body[data-mode="split"] .note-editor-pane { display: flex; width: 50%; border-right: 1px solid var(--border); }
.note-workspace-body[data-mode="split"] .note-preview-pane { display: block; width: 50%; }

/* ---------------------------------------------------------------
   Editor Footbar Stats & Actions
   --------------------------------------------------------------- */
.note-editor-footbar {
    padding: 0.65rem 1.25rem;
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.note-footbar__meta {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.note-last-edited {
    color: var(--ink-4);
    font-size: 0.78rem;
}

.note-footbar__actions {
    display: flex;
    gap: 0.5rem;
}

/* ---------------------------------------------------------------
   Modals (Share & Settings)
   --------------------------------------------------------------- */
.note-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.note-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    animation: noteModalIn .2s ease-out;
}

@keyframes noteModalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.note-modal__header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.note-modal__header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--ink);
}

.note-modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
    padding: 0 0.25rem;
}

.note-modal__close:hover {
    color: var(--ink);
}

.note-modal__body {
    padding: 1.25rem;
}

.note-modal__desc {
    margin: 0 0 1rem;
    color: var(--ink-3);
    font-size: 0.9rem;
    line-height: 1.5;
}

.note-modal__qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.note-modal__qr-frame {
    background: #ffffff;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.note-modal__qr-frame img {
    display: block;
    width: 130px;
    height: 130px;
    image-rendering: pixelated;
}

.note-modal__qr-hint {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--ink-3);
}

.note-modal__footer {
    padding: 0.85rem 1.25rem;
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .note-card {
        padding: 1.25rem;
    }
    .note-editor-screen {
        height: calc(100vh - 150px);
        max-height: none;
        border-radius: var(--radius);
    }
    .note-editor-topbar {
        padding: 0.6rem 0.85rem;
        gap: 0.5rem;
    }
    .note-format-bar {
        padding: 0.4rem 0.65rem;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .note-format-group--modes {
        margin-left: 0.5rem;
    }
    .note-workspace-body[data-mode="split"] {
        flex-direction: column;
    }
    .note-workspace-body[data-mode="split"] .note-editor-pane {
        width: 100%;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .note-workspace-body[data-mode="split"] .note-preview-pane {
        width: 100%;
        height: 50%;
    }
    .note-editor-footbar {
        padding: 0.6rem 0.85rem;
    }
}
