:root {
    --bg-color: #0f1014;
    --surface-color: #1b1e2b;
    --surface-hover: #232736;
    --primary-color: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #2d3748;
    --success-color: #10b981;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --sidebar-width: 320px;
    --footer-height: 80px;

    /* Component specific vars for theming */
    --input-bg: #14161f;
    --header-bg: rgba(20, 22, 31, 0.9);
    --panel-header-bg: rgba(27, 30, 43, 0.95);
    --badge-bg: rgba(255, 255, 255, 0.1);
    --logo-gradient: linear-gradient(90deg, #fff, #94a3b8);
    --search-bg: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --surface-color: #ffffff;
    --surface-hover: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #cbd5e1;
    --input-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.9);
    --panel-header-bg: rgba(255, 255, 255, 0.95);
    --badge-bg: rgba(0, 0, 0, 0.05);
    --logo-gradient: linear-gradient(90deg, #1e293b, #475569);
    --search-bg: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

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

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

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

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

.app-container {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    height: 60px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding: 0 1rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--logo-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    display: none;
    /* Hidden on mobile/compact */
}

@media (min-width: 768px) {
    .logo p {
        display: block;
    }
}

.badge {
    background: var(--badge-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Action Buttons */
.action-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
    font-weight: 600;
}

.action-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--primary-glow);
    filter: brightness(1.1);
}

.action-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.6;
}

.action-btn.secondary:hover {
    opacity: 1;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Upload Section */
.upload-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.drop-zone {
    width: 100%;
    max-width: 600px;
    padding: 3rem;
    background: rgba(27, 30, 43, 0.5);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    margin: 1rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.drop-zone .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

/* Sidebar & Split View */
.split-view {
    display: flex;
    gap: 1rem;
    flex: 1;
    height: calc(100% - 80px);
    /* Adjust based on header */
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* Mobile Sidebar (Drawer) logic could go here if needed, keeping it split for now as requested responsive but mostly desktop friendly */
@media (max-width: 768px) {
    .split-view {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 150px;
        /* Collapsed */
        resize: vertical;
    }
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
}

.sidebar-header h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.sidebar-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
}

.sidebar-item {
    padding: 0.75rem 1rem;
    margin-bottom: 2px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: white;
    border-left-color: var(--primary-color);
}

.editor-panel {
    flex: 1;
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    padding-bottom: var(--footer-height);
    /* Space for floating footer */
}

.editor-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-header-bg);
    flex-shrink: 0;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    gap: 1rem;
}

.editor-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsiveness for Header */
@media (max-width: 600px) {
    .editor-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }

    .editor-header h2 {
        text-align: center;
        margin-bottom: 0.5rem;
    }

    /* Target the inline style search container via specificity or JS, 
       but here we rely on the fact that flex items will stack with column direction */

    .editor-actions {
        justify-content: space-between;
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Styled Close Button */
.secondary-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.form-container {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    width: 100%;
    margin: 0 auto;
    max-width: 1000px;
    /* Readability constraint */
}

/* Form Styles */
.form-category {
    margin-bottom: 3rem;
}

.form-category h3 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    padding-bottom: 0.5rem;
    display: inline-block;
}

.field-group {
    margin-bottom: 2rem;
}

.field-question {
    display: block;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.badge-optional {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-style: italic;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Inputs */
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    transition: box-shadow 0.2s, border-color 0.2s;
}

/* Specialized Search Bar Styling */
.search-input-themed {
    width: 100%;
    padding-left: 2.2rem !important;
    background: var(--search-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 20px !important;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

input[type="number"] {
    width: 150px;
}

input[type="date"] {
    width: auto;
    min-width: 150px;
}

/* Disabled/Read-Only Styling */
.input-disabled,
input:disabled,
textarea:disabled {
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.02);
    cursor: not-allowed;
    border-color: transparent;
    color: var(--text-secondary);
}

.disabled-group .radio-option {
    opacity: 0.5;
    cursor: not-allowed;
}

.disabled-group input {
    cursor: not-allowed;
}

/* Custom Radios for O/N and V/F and G/M/F */
.radio-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.radio-option {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.radio-option:hover {
    color: var(--text-primary);
}

.radio-option input {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin: 0;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.radio-option input:checked {
    border-color: var(--primary-color);
}

.radio-option input:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
}



/* Footer (Floating) */
.app-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--footer-height);
    background: rgba(27, 30, 43, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    z-index: 10;
}

.footer-content {
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Utilities */
.hidden {
    display: none !important;
}

.empty-state {
    text-align: center;
    margin-top: 20%;
    color: var(--text-secondary);
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.badge-test-required {
    color: #ef4444;
    /* Red-500 */
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.editor-actions {
    display: flex;
    align-items: center;
}

/* FAB */
.fab-btn {
    position: fixed;
    bottom: 30px;
    /* Above footer or just in corner */
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
}

.fab-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* Sidebar Progress Indicator */
.sidebar-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-indicator {
    display: none;
    width: 20px;
    height: 20px;
    background: var(--success-color);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    margin-left: 10px;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.status-indicator.visible {
    display: flex;
}

/* Search Input Focus State */
#search-input:focus {
    background: rgba(0, 0, 0, 0.4) !important;
    border-color: var(--primary-color) !important;
}

/* Grey Toggle Checkbox */
.grey-toggle-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--text-secondary);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.grey-toggle-checkbox:hover {
    opacity: 1;
}

.grey-toggle-checkbox:checked {
    accent-color: var(--text-primary);
    opacity: 1;
}

/* Disabled Field Group */
.disabled-group {
    opacity: 0.5;
    pointer-events: none;
    /* Prevent interaction with inputs */
    filter: grayscale(100%);
}

/* Allow interaction with the toggle even if group is disabled */
.disabled-group .grey-toggle-checkbox {
    pointer-events: auto;
    filter: none;
}