/* ─── Editor Layout ─── */
.editor-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-body);
}

/* ─── Login Screen ─── */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(15, 16, 20, 0.98), var(--bg-body));
    backdrop-filter: blur(20px);
}

.login-screen[hidden] {
    display: none !important;
}

.editor-app[hidden] {
    display: none !important;
}

.login-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: fadeInUp 0.5s ease;
}

.login-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-input-wrap {
    display: flex;
    gap: 0.5rem;
}

.login-input-wrap input {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.7rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0 1.2rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--transition), transform var(--transition);
}

.login-btn:hover {
    background-color: var(--accent-hover);
    transform: scale(1.05);
}

.login-error {
    color: #ef4444;
    font-size: 0.82rem;
    margin-top: 0.75rem;
    font-weight: 500;
    animation: shake 0.4s ease;
}

.login-lockout {
    color: #fbbf24;
    font-size: 0.78rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-6px);
    }

    40%,
    80% {
        transform: translateX(6px);
    }
}

/* ─── Editor Header ─── */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    gap: 1rem;
}

.editor-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.editor-logo {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition);
}

.editor-logo:hover {
    color: var(--accent);
}

.editor-badge {
    background-color: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ─── Editor Buttons ─── */
.editor-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.editor-btn-outline {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.editor-btn-outline:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.04);
}

.editor-btn-accent {
    background-color: var(--accent);
    color: white;
}

.editor-btn-accent:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.editor-btn-danger {
    background-color: transparent;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.editor-btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
}

.editor-btn-full {
    width: 100%;
    justify-content: center;
    padding: 0.6rem;
}

/* ─── Editor Layout ─── */
.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ─── Editor Sidebar ─── */
.editor-sidebar {
    width: 280px;
    min-width: 280px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.75rem;
}

.editor-tabs {
    display: flex;
    gap: 0.25rem;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 3px;
}

.editor-tab {
    flex: 1;
    padding: 0.45rem;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition);
}

.editor-tab.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.editor-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* ─── Items List ─── */
.items-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.items-list::-webkit-scrollbar {
    width: 4px;
}

.items-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.item-entry {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.item-entry:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.item-entry.active {
    background-color: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
}

.item-entry-title {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-entry-date {
    font-size: 0.68rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ─── Editor Main ─── */
.editor-main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ─── Empty State ─── */
.editor-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    gap: 0.5rem;
}

.editor-empty[hidden] {
    display: none !important;
}

.editor-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ─── Edit Form ─── */
.editor-form,
.editor-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

.editor-form[hidden],
.editor-preview[hidden] {
    display: none !important;
}

.editor-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.editor-form-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.editor-form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ─── Fields ─── */
.editor-fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field-group input,
.field-group select {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.field-group input:focus,
.field-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.field-group select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.field-group select option {
    background-color: #1a1a1a;
    color: var(--text-primary);
}

.field-row {
    display: flex;
    gap: 1rem;
}

.field-row .field-group {
    flex: 1;
}

/* ─── Quill Editor ─── */
.field-group-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#quill-toolbar {
    background-color: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--border-subtle) !important;
    border-bottom: none !important;
    border-radius: 10px 10px 0 0 !important;
    padding: 6px 8px !important;
}

#quill-editor {
    flex: 1;
    min-height: 300px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 0 10px 10px !important;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    line-height: 1.7;
}

/* Quill dark theme overrides */
.ql-toolbar .ql-stroke {
    stroke: var(--text-secondary) !important;
}

.ql-toolbar .ql-fill {
    fill: var(--text-secondary) !important;
}

.ql-toolbar .ql-picker-label {
    color: var(--text-secondary) !important;
}

.ql-toolbar .ql-picker-options {
    background-color: #1a1b20 !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 8px !important;
    padding: 4px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

.ql-toolbar .ql-picker-item {
    color: var(--text-secondary) !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
}

.ql-toolbar .ql-picker-item:hover {
    color: var(--text-primary) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.ql-toolbar button:hover .ql-stroke {
    stroke: var(--text-primary) !important;
}

.ql-toolbar button:hover .ql-fill {
    fill: var(--text-primary) !important;
}

.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent) !important;
}

.ql-toolbar button.ql-active .ql-fill {
    fill: var(--accent) !important;
}

.ql-toolbar .ql-picker-label:hover {
    color: var(--text-primary) !important;
}

.ql-editor.ql-blank::before {
    color: #555 !important;
    font-style: normal !important;
}

.ql-snow .ql-tooltip {
    background-color: #1a1b20 !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 8px !important;
    color: var(--text-primary) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

.ql-snow .ql-tooltip input[type="text"] {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 6px !important;
    color: var(--text-primary) !important;
}

.ql-snow .ql-tooltip a.ql-action,
.ql-snow .ql-tooltip a.ql-remove {
    color: var(--accent) !important;
}

/* Code blocks in Quill */
.ql-editor pre.ql-syntax {
    background-color: #1e1e2e !important;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-x: auto;
    color: #cdd6f4;
}

/* ─── Article Content (Preview & Article Page) ─── */
.article-content {
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.85;
    max-width: 720px;
}

.article-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 2rem 0 1rem;
    color: var(--text-primary);
}

.article-content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 1.75rem 0 0.75rem;
    color: var(--text-primary);
}

.article-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    color: var(--text-primary);
}

.article-content p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.article-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.article-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.article-content a:hover {
    color: var(--accent-hover);
}

.article-content ul,
.article-content ol {
    margin: 0.75rem 0 1rem 1.5rem;
    color: var(--text-secondary);
}

.article-content li {
    margin-bottom: 0.35rem;
}

.article-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1.25rem;
    margin: 1rem 0;
    background-color: rgba(59, 130, 246, 0.05);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.article-content pre {
    background-color: #1e1e2e !important;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.25rem;
    margin: 1.25rem 0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-x: auto;
    color: #cdd6f4;
}

.article-content code {
    background-color: rgba(255, 255, 255, 0.06);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    color: #f38ba8;
}

.article-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 1.25rem 0;
    border: 1px solid var(--border-subtle);
}

/* ─── Notifications / Toast ─── */
.editor-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editor-toast.success {
    border-color: rgba(34, 197, 94, 0.3);
}

.editor-toast.error {
    border-color: rgba(239, 68, 68, 0.3);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .editor-layout {
        flex-direction: column;
    }

    .editor-sidebar {
        width: 100%;
        min-width: 0;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .editor-form,
    .editor-preview {
        padding: 1rem;
    }

    .field-row {
        flex-direction: column;
    }

    .editor-header {
        flex-wrap: wrap;
        padding: 0.6rem 1rem;
    }

    .editor-header-right {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .editor-form-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-form-actions {
        width: 100%;
    }

    .editor-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.7rem;
    }
}