/* Base 2 Notes — Components */

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-danger);
    color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-danger-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 8px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: 6px;
    border-radius: var(--radius-md);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ── Form Elements ── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-error {
    color: var(--color-danger);
    font-size: 0.8125rem;
    margin-top: 4px;
    min-height: 20px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    transform: translateY(10px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 0 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastSlideIn 0.3s ease;
    max-width: 380px;
}

.toast.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast.toast-error {
    border-left: 4px solid var(--color-danger);
}

.toast.toast-warning {
    border-left: 4px solid var(--color-warning);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── Dropdown ── */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 500;
    display: none;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item.danger {
    color: var(--color-danger);
}

.dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.dropdown-label {
    padding: 6px 16px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Tags ── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: default;
}

.tag-removable {
    cursor: pointer;
}

.tag-removable:hover {
    opacity: 0.8;
}

/* ── Context Menu (right-click) ── */
.context-menu {
    position: fixed;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 1500;
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu .dropdown-item.has-submenu {
    justify-content: space-between;
    cursor: default;
}

.context-menu .dropdown-item.has-submenu::after {
    content: '\25B6';
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-left: 12px;
    flex-shrink: 0;
}

.context-menu .dropdown-item.has-submenu:hover::after {
    color: var(--text-primary);
}

.context-menu .context-submenu {
    position: fixed;
}

.context-menu .dropdown-item .ctx-check {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-primary);
    margin-right: 4px;
}

/* ── Loading Spinner ── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Selection ── */
::selection {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* ── Theme Editor ── */
.theme-editor-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    z-index: 1100;
    display: none;
    justify-content: flex-end;
}

.theme-editor-overlay.active {
    display: flex;
}

.theme-editor {
    width: 360px;
    max-width: 90vw;
    height: 100%;
    max-height: 100dvh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.25s ease;
}

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

.theme-editor-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.theme-editor-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.theme-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.theme-section {
    margin-bottom: 20px;
}

.theme-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color-light);
}

.theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.theme-row label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.theme-row input[type="color"] {
    width: 36px;
    height: 28px;
    padding: 1px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

.theme-row input[type="color"]:hover {
    border-color: var(--color-primary);
}

.theme-select {
    width: 180px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    cursor: pointer;
}

.theme-editor-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ── Settings Controls ── */

.settings-value {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 44px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.theme-row input[type="range"] {
    flex: 1;
    max-width: 120px;
    accent-color: var(--color-primary);
    margin: 0 8px;
}

.settings-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    cursor: pointer;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 11px;
    transition: background var(--transition-fast);
}

.settings-toggle-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: var(--bg-main);
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.settings-toggle input:checked + .settings-toggle-track {
    background: var(--color-primary);
}

.settings-toggle input:checked + .settings-toggle-track::after {
    transform: translateX(16px);
}

.theme-section-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0 20px;
    position: relative;
}

.theme-section-divider::after {
    content: 'THEME COLORS';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 0 10px;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* ── Folder Drag-and-Drop ── */
.folder-dragging {
    opacity: 0.5;
}

.folder-drag-over-before {
    box-shadow: inset 0 2px 0 0 var(--color-primary);
}

.folder-drag-over-inside {
    background: var(--color-primary-light) !important;
}

.folder-drag-over-after {
    box-shadow: inset 0 -2px 0 0 var(--color-primary);
}
