/* CSS Custom Properties */
:root {
    /* Colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --bg-hover: #eee;
    --bg-active: #e8f0fe;

    --text-primary: #1a1a1a;
    --text-secondary: #444;
    --text-tertiary: #555;
    --text-muted: #666;
    --text-faint: #888;
    --text-completed: #adb5bd;

    --border-color: #e5e5e5;
    --border-light: #eee;

    /* Primary/Accent color - professional blue (matches cardstack/docstack) */
    --accent-color: #0066cc;
    --accent-hover: #0052a3;

    /* Header - dark, contrasting (matches cardstack/docstack) */
    --header-bg: #1a1a2e;
    --header-text: #ffffff;
    --header-text-muted: rgba(255, 255, 255, 0.7);

    --priority-high: #fa5252;
    --priority-medium: #fab005;
    --priority-low: #40c057;

    /* Status colors */
    --success: #059669;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --warning: #d97706;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;

    --checkbox-size: 20px;
    --checkbox-border: #ced4da;
    --checkbox-checked: #228be6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;

    /* Layout */
    --header-height: 56px;
    --max-width: 1600px;
    --content-max-width: 700px;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #242424;
        --bg-tertiary: #2d2d2d;
        --bg-hover: #333;
        --bg-active: #1e3a5f;

        --text-primary: #e5e5e5;
        --text-secondary: #ccc;
        --text-tertiary: #bbb;
        --text-muted: #999;
        --text-faint: #777;
        --text-completed: #495057;

        --border-color: #404040;
        --border-light: #333;

        /* Dark mode header */
        --header-bg: #0d0d0d;

        /* Dark mode accent */
        --accent-color: #4da6ff;
        --accent-hover: #80bdff;

        --checkbox-border: #495057;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);

        /* Dark mode status colors */
        --success-bg: #064e3b;
        --success-text: #6ee7b7;
        --danger-bg: #7f1d1d;
        --danger-text: #fca5a5;
    }
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Site Header - matches cardstack/docstack pattern */
.site-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--header-bg);
    z-index: 1000;
}

.site-header > div,
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-left {
    flex: 1;
}

.header-right {
    flex: 1;
    justify-content: flex-end;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--header-text);
    text-decoration: none;
    white-space: nowrap;
}

.site-logo:hover {
    text-decoration: none;
    color: var(--header-text);
}

.site-logo-emoji {
    font-size: 28px;
    line-height: 1;
}

.site-logo img {
    height: 24px;
    width: auto;
}

/* App Container - pushes footer below fold */
.app {
    min-height: calc(100vh - var(--header-height));
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 24px 20px;
}

/* Header button styling for dark header */
.site-header .btn-icon {
    color: var(--header-text-muted);
    background: transparent;
    border: none;
}

.site-header .btn-icon:hover {
    color: var(--header-text);
    background: rgba(255, 255, 255, 0.1);
}

/* External Link (for dark header) - matches docstack/cardstack */
.header-external-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--header-text-muted);
    padding: 8px 12px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.header-external-link:hover {
    color: var(--header-text);
    text-decoration: none;
}

.header-external-link img {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

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

.btn:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

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

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

.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #059669;
    color: white;
    border-radius: 9999px;
}

.admin-badge svg {
    flex-shrink: 0;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-add-section {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--text-muted);
    border: 2px dashed var(--border-color);
    margin-top: 16px;
}

.btn-add-section:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: var(--bg-hover);
}

/* Global Input */
.global-input-container {
    margin-bottom: 24px;
}

.global-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.global-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.global-input::placeholder {
    color: var(--text-muted);
}

/* Sections */
.sections-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    user-select: none;
}

.section-header:hover {
    background: var(--bg-hover);
}

.section-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.section.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-title {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.section-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.section-header:hover .section-actions {
    opacity: 1;
}

.section-action-btn {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.section-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.section-content {
    padding: 8px 0;
}

.section.collapsed .section-content {
    display: none;
}

/* Hide section header when there's only one untitled section */
.section.single-untitled .section-header {
    display: none;
}

.section.single-untitled .section-content {
    padding-top: 8px;
}

/* Section Input */
.section-input-container {
    padding: 8px 16px;
}

.section-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.section-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: var(--bg-primary);
}

.section-input::placeholder {
    color: var(--text-muted);
}

/* Items */
.items-list {
    list-style: none;
}

.item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.item:last-child {
    border-bottom: none;
}

.item:hover {
    background: var(--bg-hover);
}

.item.completed {
    opacity: 0.6;
}

.item.completed .item-title {
    text-decoration: line-through;
    color: var(--text-completed);
}

/* Nested Items */
.item.depth-1 { padding-left: 24px; }
.item.depth-2 { padding-left: 40px; }
.item.depth-3 { padding-left: 56px; }

/* Checkbox */
.item-checkbox {
    position: relative;
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    flex-shrink: 0;
    margin-top: 2px;
}

.item-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

.item-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    background: var(--bg-primary);
    border: 2px solid var(--checkbox-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.item-checkbox input:checked + .checkmark {
    background: var(--checkbox-checked);
    border-color: var(--checkbox-checked);
}

.item-checkbox .checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.item-checkbox input:checked + .checkmark::after {
    display: block;
}

/* Item Content */
.item-content {
    flex: 1;
    min-width: 0;
}

.item-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-word;
    cursor: text;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.item-title:hover {
    background: var(--bg-hover);
}

.inline-title-input {
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    margin: -3px -5px;
    width: calc(100% + 10px);
    outline: none;
}

.item-details-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.item:hover .item-details-btn {
    opacity: 1;
}

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

.item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-due-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.item-due-date.overdue {
    color: var(--danger-color);
}

.item-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.item-priority.high { background: var(--priority-high); }
.item-priority.medium { background: var(--priority-medium); }
.item-priority.low { background: var(--priority-low); }

.item-has-description {
    display: inline-flex;
    align-items: center;
}

.item-subtask-count {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Item Expand Toggle */
.item-expand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

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

.item-expand.collapsed {
    transform: rotate(-90deg);
}

.item-children {
    margin-left: 16px;
}

.item-children.hidden {
    display: none;
}

/* Child item styling */
.child-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 0;
}

.child-item .item-title {
    font-size: 0.875rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 1000;
}

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

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

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

.modal.modal-sm {
    max-width: 400px;
}

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

.modal-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}


.modal-close {
    flex-shrink: 0;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* Form Elements */
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Modal Children */
.modal-children {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.modal-children-header {
    margin-bottom: 12px;
}

.children-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.children-list:empty {
    display: none;
}

.child-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.child-row.completed .child-title {
    text-decoration: line-through;
    color: var(--text-completed);
}

.child-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.child-title {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.child-delete {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition-fast);
}

.child-row:hover .child-delete {
    opacity: 1;
}

.child-delete:hover {
    color: var(--danger-color);
    background: var(--bg-hover);
}

.add-child-container {
    margin-top: 8px;
}

/* Modal Meta */
.modal-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Delete Button */
.btn-delete {
    width: 100%;
    margin-top: 20px;
}

/* Settings */
.setting-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.setting-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

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

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

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

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

.context-menu-separator {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* Drag and Drop */
.item.dragging {
    opacity: 0.5;
}

.item.drag-over {
    border-top: 2px solid var(--accent-color);
}

/* Section Drag Handle */
.section-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    cursor: grab;
    opacity: 0;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.section-header:hover .section-drag-handle {
    opacity: 1;
}

.section-drag-handle:active {
    cursor: grabbing;
}

/* Section drag states */
.section.section-dragging {
    opacity: 0.5;
}

.section.section-drop-target {
    border-top: 3px solid var(--accent-color);
}

/* Inline Subtask Input */
.inline-subtask-container {
    padding: 4px 16px 8px 0;
}

.inline-subtask-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.inline-subtask-input:focus {
    outline: none;
    border-style: solid;
    border-color: var(--accent-color);
    background: var(--bg-primary);
}

.inline-subtask-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Always show expand button (but dimmed) */
.item-expand {
    opacity: 0.4;
}

.item:hover .item-expand,
.item-expand:focus {
    opacity: 1;
}

/* ============================================
   Password Protection Page
   ============================================ */
.password-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height));
    background: var(--bg-secondary);
    padding: 20px;
}

.password-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.password-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.password-container h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.password-section-name {
    color: var(--text-muted);
    margin: 0 0 24px 0;
    font-size: 15px;
}

.password-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

@media (prefers-color-scheme: dark) {
    .password-error {
        background: #450a0a;
        color: #fca5a5;
    }
}

.password-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.password-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.password-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.password-submit {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 500;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.password-submit:hover {
    background: var(--accent-hover);
}

/* Site Footer - matches cardstack/docstack pattern */
.site-footer {
    padding: 20px 16px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.site-footer .footer-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.site-footer .powered-by {
    font-size: 12px;
    color: var(--text-faint);
}

.site-footer .powered-by a {
    color: var(--text-muted);
    text-decoration: none;
}

.site-footer .powered-by a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
    .app {
        padding: 12px;
    }

    .app-title {
        font-size: 1.25rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }

    .section-actions {
        opacity: 1;
    }

    .section-drag-handle {
        opacity: 1;
    }

    .item-expand {
        opacity: 1;
    }

    .item-details-btn {
        opacity: 1;
    }

    .user-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .user-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation removed - was replaying on every list update */

/* Focus States for Accessibility */
.btn:focus-visible,
.item-checkbox input:focus-visible + .checkmark,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* ========================================
   User Menu
   ======================================== */

.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-menu-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-dark);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
    z-index: 1000;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-info {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-menu-email {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-all;
}

.user-menu-role {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.user-menu-role.role-admin {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.user-menu-item:hover {
    background: var(--bg-hover);
    text-decoration: none;
    color: var(--text-primary);
}

.user-menu-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.user-menu-item-danger {
    color: #dc2626;
}

.user-menu-item-danger svg {
    color: #dc2626;
}

.user-menu-item-danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

/* ========================================
   Users Page
   ======================================== */

.users-page-container {
    padding: 32px 16px;
    max-width: 900px;
    margin: 0 auto;
}

.users-page {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.users-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease;
}

.user-card:hover {
    border-color: var(--accent-color);
}

.user-card-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-card-email {
    font-weight: 500;
    color: var(--text-primary);
}

.user-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.role-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 500;
}

.role-admin {
    background: #dbeafe;
    color: #1d4ed8;
}

.role-readonly {
    background: #f3f4f6;
    color: #6b7280;
}

@media (prefers-color-scheme: dark) {
    .role-admin {
        background: #1e3a5f;
        color: #60a5fa;
    }

    .role-readonly {
        background: #374151;
        color: #9ca3af;
    }
}

.super-admin-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: #8b5cf6;
    color: white;
    border-radius: 9999px;
    font-weight: 500;
}

.user-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-card-actions .text-muted {
    align-self: center;
    margin-top: -2px;
}

.users-empty,
.empty-state {
    padding: 12px 0;
    color: var(--text-muted);
}

/* Form Help Text */
.form-help {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 8px;
}

/* ========================================
   Attachments
   ======================================== */

.modal-attachments {
    margin-top: 20px;
}

.modal-attachments-header {
    margin-bottom: 12px;
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.attachments-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 0;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}

.attachment-thumbnail {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.attachment-icon {
    width: 60px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    color: var(--text-muted);
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-name:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.attachment-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.attachment-actions {
    flex-shrink: 0;
}

.attachment-delete {
    color: var(--text-muted);
}

.attachment-delete:hover {
    color: var(--danger-color);
}

/* Attachment badge on items */
.item-attachment-count {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.item-attachment-count svg {
    opacity: 0.7;
}

/* ========================================
   Search Modal
======================================== */

.search-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 20px 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
}

.search-modal.show {
    opacity: 1;
    visibility: visible;
}

.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.search-modal-content {
    position: relative;
    background-color: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 560px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-10px);
    transition: transform 0.15s ease;
}

.search-modal.show .search-modal-content {
    transform: translateY(0);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.search-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-muted);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 100px;
}

.search-result {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.1s;
}

.search-result:hover,
.search-result.selected {
    background-color: var(--bg-tertiary);
}

.search-result-completed .search-result-title {
    color: var(--text-completed);
    text-decoration: line-through;
}

.search-result-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.search-result-title mark {
    background-color: rgba(59, 130, 246, 0.2);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-preview {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.search-result-preview mark {
    background-color: rgba(59, 130, 246, 0.2);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-path {
    font-size: 12px;
    color: var(--text-muted);
}

.search-empty,
.search-loading {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.search-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.search-hint {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.search-hint kbd {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
}

@media (max-width: 600px) {
    .search-modal {
        padding: 5vh 12px 12px;
    }

    .search-modal-content {
        max-height: 80vh;
    }

    .search-footer {
        display: none;
    }
}

@media (prefers-color-scheme: dark) {
    .search-modal-backdrop {
        background-color: rgba(0, 0, 0, 0.7);
    }

    .search-result-title mark,
    .search-result-preview mark {
        background-color: rgba(59, 130, 246, 0.3);
    }
}

/* ========================================
   Cleanup Modal
======================================== */

.cleanup-summary {
    font-size: 14px;
    line-height: 1.6;
}

.cleanup-summary p {
    margin: 0 0 12px 0;
}

.cleanup-summary p:last-child {
    margin-bottom: 0;
}

.cleanup-file-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 12px 0;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    list-style: none;
}

.cleanup-file-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-family: monospace;
}

.cleanup-file-list li:last-child {
    border-bottom: none;
}

.cleanup-stats {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* ========================================
   User List Selector
======================================== */

.user-list-selector {
    margin-left: 16px;
}

.user-list-selector select {
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--header-text);
    cursor: pointer;
    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='rgba(255,255,255,0.7)' 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 8px center;
}

.user-list-selector select:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.user-list-selector select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.user-list-selector select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ========================================
   Viewing Indicator
======================================== */

.viewing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-active);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.viewing-indicator svg {
    color: var(--text-muted);
}

.readonly-badge {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ========================================
   Send Item Button & Indicator
======================================== */

.item-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.item:hover .item-send-btn {
    opacity: 1;
}

.item-send-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-color);
}

.item-sent-from {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 500;
}

.item-sent-from svg {
    opacity: 0.8;
}

/* ========================================
   Send Modal
======================================== */

.send-modal-description {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

#send-confirm svg {
    margin-right: 2px;
}

@media (max-width: 600px) {
    .user-list-selector {
        margin-left: 12px;
    }

    .user-list-selector select {
        max-width: 140px;
    }

    .item-send-btn {
        opacity: 1;
    }
}
