/* ============================================
   NO-FIELD SCANNER - MASTER STYLE SHEET
   Design tokens and global overrides
   ============================================ */

:root {
    /* === COLOR TOKENS === */
    /* Background Hierarchy (darkest to lightest) */
    --bg: #0a0e1a;              /* Base background - darkest */
    --bg-elevated: #0f1424;     /* Slightly elevated surfaces */
    --bg-panel: #141b2d;        /* Panel/card background */
    
    /* Legacy aliases for compatibility */
    --panel-bg: var(--bg-panel);
    --panel: var(--bg-elevated);
    
    /* Text Colors */
    --text: #e8ecff;
    --muted: #a9b3da;
    --border: rgba(255, 255, 255, 0.1);
    
    /* Accent Colors */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    
    /* Status Colors */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --success-border: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: #ef4444;
    --info: #3b82f6;
    
    /* Interactive States */
    --hover-bg: rgba(255, 255, 255, 0.05);
    --hover-bg-strong: rgba(255, 255, 255, 0.1);
    --active-bg: rgba(255, 255, 255, 0.08);
    --selected-bg: rgba(59, 130, 246, 0.2);
    
    /* === SPACING TOKENS === */
    --spacing-xs: 2px;
    --spacing-sm: 4px;
    --spacing-md: 8px;
    --spacing-lg: 12px;
    --spacing-xl: 16px;
    
    /* === TYPOGRAPHY TOKENS === */
    --font-size-xs: 10px;
    --font-size-sm: 11px;
    --font-size-md: 12px;
    --font-size-base: 14px;
    --font-size-lg: 16px;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* === BORDER RADIUS === */
    --radius-sm: 3px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-xl: 8px;
    
    /* === SHADOWS === */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* === GLOBAL RESETS & BASE === */
* {
    box-sizing: border-box;
}

/* === SCROLLBARS - blueish dark theme === */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.45) var(--bg-elevated);
}
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: var(--bg-elevated);
}
*::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.35);
    border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.55);
}
*::-webkit-scrollbar-corner {
    background: var(--bg-elevated);
}

/* === SHARED COMPONENT CLASSES === */

/* Volume Row (used in niivue_app.js) */
.volume-row {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: background 0.2s ease;
}

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

.volume-row.selected {
    background: var(--success-bg);
}

.volume-row.scan-item {
    border-left: 3px solid var(--success);
}

.volume-row.scan-item.selected {
    border-left: 4px solid var(--success);
}

.volume-row.mask-item {
    border-left: 3px solid var(--accent);
}

.volume-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.volume-row-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.volume-row-meta {
    font-size: var(--font-size-xs);
    color: var(--muted);
    margin-top: 1px;
    opacity: 0.8;
}

.volume-row-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.volume-row-btn,
.btn.volume-row-btn {
    width: 20px !important;
    min-width: 20px !important;
    height: 20px !important;
    padding: 0 !important;
    font-size: 9px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    aspect-ratio: 1;
    flex-shrink: 0;
}

.volume-row-btn:hover:not(:disabled),
.btn.volume-row-btn:hover:not(:disabled) {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: white !important;
}

.volume-row-btn .bi,
.dl-seq-btn .bi,
.remove-job-btn .bi {
    font-size: 1em;
    line-height: 1;
    display: block;
    width: 1em;
    height: 1em;
}

/* Section Header (used in niivue_app.js) */
.section-header {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--accent);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-sm);
    border-left: 2px solid var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Parameter Table (used in seq_explorer.js) */
.params-table {
    width: 100%;
    border-collapse: collapse;
}

.params-table-row {
    border-bottom: 1px solid var(--border);
}

.params-table-label-cell {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    font-weight: var(--font-weight-medium);
    color: var(--muted);
    width: 40%;
}

.params-table-input-cell {
    padding: 0.4rem 0.5rem;
    width: 50%;
}

.params-table-type-cell {
    padding: 0.4rem 0.5rem;
    width: 10%;
    text-align: right;
}

.params-input {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.8rem;
}

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

.params-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.params-checkbox {
    margin-right: 0.5rem;
}

.params-type-tag {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    padding: 0.1rem 0.3rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

/* Upload button in params table - match app button style */
.params-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.3);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.25rem;
}

.params-upload-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.params-upload-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* === UNIFIED BUTTON SYSTEM === */

/* Base Button Class - All buttons inherit from this
   This overrides module-specific .btn styles since this file loads last */
.btn,
.niivue-app .btn,
.seq-explorer .btn,
.scan-module .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.3);
    color: var(--text);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    user-select: none;
}

.btn:hover:not(:disabled),
.btn.btn-secondary:hover:not(:disabled),
.btn.volume-row-btn:hover:not(:disabled) {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: white !important;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

/* Button Size Modifiers */
.btn-sm {
    padding: var(--spacing-xs) 6px;
    font-size: var(--font-size-xs);
    height: 20px;
    border-radius: var(--radius-sm);
}

.btn-md {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    height: auto;
    min-height: 24px;
}

.btn-lg {
    padding: var(--spacing-lg);
    font-size: var(--font-size-md);
    height: auto;
    min-height: 36px;
}

/* Note: All button variants (.btn-primary, .btn-secondary, etc.) 
   inherit from base .btn - no separate definitions needed since 
   they all share the same subtle blue default + blue hover */

/* Button Layout Modifiers */
.btn-flex {
    flex: 1;
}

.btn-full {
    width: 100%;
}

/* Special Button Classes - Scan Module specific buttons */

/* Scan Button - Large action button (inherits base but adds scan-specific style) */
.scan-btn {
    width: 100%;
    padding: var(--spacing-lg);
    background: var(--success);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    transition: all 0.2s;
    font-size: var(--font-size-md);
}

.scan-btn:hover {
    background: #16a34a;
    transform: scale(1.02);
}

.scan-btn:active {
    transform: scale(0.98);
}

/* Queue Action Buttons - Small uppercase buttons for scan queue */
.view-btn,
.view-seq-btn {
    background: rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: var(--text);
    font-size: 9px;
    font-weight: var(--font-weight-bold);
    padding: var(--spacing-xs) 6px;
    height: 20px;
    min-width: 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Icon-only square buttons (download / remove) */
.dl-seq-btn,
.remove-job-btn {
    width: 20px;
    min-width: 20px;
    height: 20px;
    padding: 0;
    box-sizing: border-box;
    aspect-ratio: 1;
    flex-shrink: 0;
    background: rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: var(--text);
    font-size: 9px;
    font-weight: var(--font-weight-bold);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover,
.view-seq-btn:hover,
.dl-seq-btn:hover,
.remove-job-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Header Styles */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    width: 100%;
}

.header-title {
    font-weight: var(--font-weight-bold);
    font-size: 1.1rem;
}

.header-subtitle {
    font-weight: var(--font-weight-normal);
    color: var(--accent);
}

.credits-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.credits-btn:hover {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
}

.credits-btn .bi {
    font-size: 1.1rem;
}

.credits-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.credits-overlay[hidden] {
    display: none;
}

.credits-modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

.credits-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: var(--font-weight-bold);
}

.credits-close {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.credits-close:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.credits-content {
    padding: 1.25rem;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

.credits-content h2 {
    font-size: 1rem;
    margin: 1rem 0 0.5rem;
    color: var(--accent);
}

.credits-content h2:first-child {
    margin-top: 0;
}

.credits-content h3 {
    font-size: 0.95rem;
    margin: 0.75rem 0 0.35rem;
}

.credits-content p, .credits-content ul {
    margin: 0.35rem 0;
}

.credits-content a {
    color: var(--accent);
    text-decoration: none;
}

.credits-content a:hover {
    text-decoration: underline;
}

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

#col-scan {
    padding: 0;
}

#module-cache {
    display: none;
}

/* === MODULE TOKEN PROPAGATION === */
/* Ensure all modules inherit the same design tokens */
.niivue-app,
.seq-explorer,
.scan-module {
    --bg: #0a0e1a;
    --bg-elevated: #0f1424;
    --bg-panel: #141b2d;
    --panel-bg: var(--bg-panel);
    --panel: var(--bg-elevated);
    --text: #e8ecff;
    --muted: #a9b3da;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3b82f6;
}

/* Module backgrounds - transparent to inherit from containers */
.niivue-app,
.seq-explorer,
.scan-module {
    background: transparent;
    color: var(--text);
}

/* Seq Explorer section backgrounds */
#seq-explorer-section,
#seq-params-section {
    background: transparent;
    border: none;
}

.seq-explorer .seq-function-item.selected {
    background: var(--selected-bg);
    border-left-color: var(--accent);
}

/* Seq Plot container */
.seq-plot-container,
#seq-plot-output {
    background: var(--bg);
}

/* Matplotlib toolbar harmonization */
.mpl-toolbar {
    background: var(--bg-elevated) !important;
    border-bottom: 1px solid var(--border) !important;
}
