/**
 * COSMO Design System
 * Unified styles for all dashboards
 * Based on the web launcher's modern design
 */

/* =============================================================================
   RESET & BASE
   ============================================================================= */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    color: #c9d1d9;
    font-size: 13px;
    line-height: 1.5;
    min-height: 100vh;
}

/* =============================================================================
   COLORS (CSS Variables)
   ============================================================================= */

:root {
    --bg-darkest: #0d1117;
    --bg-dark: #161b22;
    --bg-medium: #21262d;
    
    --border-subtle: #21262d;
    --border-default: #30363d;
    --border-hover: #484f58;
    
    --accent-blue: #58a6ff;
    --accent-green: #238636;
    --accent-orange: #f39c12;
    --accent-red: #da3633;
    
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* =============================================================================
   LAYOUT
   ============================================================================= */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.main-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    margin-bottom: 80px;
}

.sidebar {
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border-default);
    padding: 20px;
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-darkest);
    border-radius: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* =============================================================================
   SECTIONS & PANELS
   ============================================================================= */

.section {
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border-default);
    padding: 20px;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-default);
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-orange);
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* Collapsible Sections */
.config-section {
    margin-bottom: 20px;
    background: var(--bg-darkest);
    border-radius: 8px;
    border: 1px solid var(--border-default);
    overflow: hidden;
}

.config-section h3 {
    font-size: 14px;
    margin: 0;
    padding: 15px 18px;
    color: var(--accent-orange);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: var(--bg-darkest);
    border-bottom: 1px solid var(--border-default);
    transition: background 0.2s;
}

.config-section h3:hover {
    background: var(--bg-dark);
}

.config-section-content {
    padding: 20px;
}

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

.config-section.collapsed h3 {
    border-bottom: none;
}

.collapse-icon {
    transition: transform 0.2s;
    font-size: 12px;
}

.config-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* =============================================================================
   TABLES
   ============================================================================= */

.clean-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.clean-table thead th {
    text-align: left;
    padding: 12px 10px;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-default);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clean-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-subtle);
}

.clean-table tbody tr:hover {
    background: rgba(88, 166, 255, 0.05);
}

.clean-table tbody tr.selected {
    background: rgba(88, 166, 255, 0.12);
}

.clean-table tbody td {
    padding: 16px 10px;
    vertical-align: middle;
}

/* =============================================================================
   FORMS
   ============================================================================= */

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-darkest);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.form-textarea {
    min-height: 60px;
    resize: vertical;
}

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

.help-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* =============================================================================
   TOGGLE SWITCHES
   ============================================================================= */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-default);
    transition: .3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: var(--text-secondary);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--accent-green);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-darkest);
    border-radius: 6px;
    margin-bottom: 10px;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: #2ea043;
}

.btn-secondary {
    background: var(--bg-medium);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

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

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

.btn-danger:hover {
    background: #f85149;
}

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

/* =============================================================================
   BADGES & PILLS
   ============================================================================= */

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: var(--accent-green);
    color: white;
}

.badge-info {
    background: var(--accent-blue);
    color: white;
}

.badge-warning {
    background: var(--accent-orange);
    color: white;
}

.badge-danger {
    background: var(--accent-red);
    color: white;
}

.badge-neutral {
    background: var(--bg-medium);
    color: var(--text-secondary);
}

/* =============================================================================
   ALERTS
   ============================================================================= */

.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
}

.alert-info {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
}

.alert-danger {
    background: rgba(218, 54, 51, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.alert-success {
    background: rgba(35, 134, 54, 0.1);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

/* =============================================================================
   MODALS
   ============================================================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border-default);
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* =============================================================================
   LOADING STATES
   ============================================================================= */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--border-default);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============================================================================
   UTILITIES
   ============================================================================= */

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

.text-secondary {
    color: var(--text-secondary);
}

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

.text-success {
    color: var(--accent-green);
}

.text-danger {
    color: var(--accent-red);
}

.text-warning {
    color: var(--accent-orange);
}

.text-info {
    color: var(--accent-blue);
}

/* Specific color utilities */
.text-complete { color: #57d9a3; }
.text-incomplete { color: #f0ad4e; }
.text-purple { color: #9d4edd; }
.text-green { color: #2ecc71; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }

.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }

.p-10 { padding: 10px; }
.p-15 { padding: 15px; }
.p-20 { padding: 20px; }

/* =============================================================================
   SPECIFIC COMPONENTS
   ============================================================================= */

/* Stat Cards */
.stat-card {
    background: var(--bg-darkest);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    padding: 15px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tabs (Enhanced) */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-default);
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(88, 166, 255, 0.05);
}

.tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* Code Blocks */
.code-block {
    background: var(--bg-darkest);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    padding: 15px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 12px;
    overflow-x: auto;
    color: var(--text-primary);
}

.code-block::-webkit-scrollbar {
    height: 6px;
}

.code-block::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 14px;
}

/* Progress Bars */
.progress-bar {
    height: 8px;
    background: var(--border-subtle);
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), #57d9a3);
    transition: width 0.3s;
}

.progress-lg .progress-bar {
    height: 12px;
}

.progress-sm .progress-bar {
    height: 6px;
}

/* Table Enhancements */
.table-sm th {
    padding: 6px 8px;
    font-size: 10px;
}

.table-sm td {
    padding: 8px;
    font-size: 12px;
}

/* Run Configuration Card */
.run-config-card {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 3px solid var(--accent-blue);
}

.run-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.run-config-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.config-table {
    font-size: 12px;
    width: 100%;
}

.config-table td {
    padding: 4px 8px;
    border: none;
}

.config-table td:first-child {
    color: var(--text-secondary);
    width: 180px;
}

.config-table td:last-child {
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: flex;
    gap: 30px;
    padding: 15px;
    background: var(--bg-dark);
    border-radius: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 6px;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-item label {
    font-size: 12px;
    color: var(--text-secondary);
}

.filter-item input,
.filter-item select {
    padding: 6px 10px;
    background: var(--bg-darkest);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
}

.filter-item input:focus,
.filter-item select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Quick Action Buttons */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-action-btn {
    padding: 6px 12px;
    background: var(--border-subtle);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--border-default);
    border-color: var(--border-hover);
}

/* Info Banner */
.info-banner {
    background: #1f2937;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent-blue);
}

.info-banner-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.info-banner-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

/* Action Panel */
.action-panel {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-darkest);
    border-radius: 6px;
    border: 1px solid var(--border-default);
}

.action-panel-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-orange);
    margin-bottom: 8px;
}

.action-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-controls select,
.action-controls input {
    padding: 6px 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
}

.action-controls input {
    flex: 1;
    width: auto; /* Override .form-input width: 100% */
    min-width: 200px; /* Ensure input is visible */
}

.action-controls select {
    flex-shrink: 0;
    width: auto; /* Override .form-select width: 100% */
}

.action-note {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

/* Export Controls */
.export-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.export-controls label {
    font-size: 11px;
    color: var(--text-secondary);
}

.export-controls select {
    padding: 6px 10px;
    background: var(--bg-darkest);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

/* Text Utilities */
.text-mono {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

.font-10 { font-size: 10px; }
.font-11 { font-size: 11px; }
.font-12 { font-size: 12px; }
.font-13 { font-size: 13px; }
.font-14 { font-size: 14px; }
.font-18 { font-size: 18px; }
.font-20 { font-size: 20px; }

.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Width Utilities */
.w-60 { width: 60px; }
.w-80 { width: 80px; }
.w-100 { width: 100px; }
.w-120 { width: 120px; }
.w-180 { width: 180px; }
.w-200 { width: 200px; }
.w-300 { width: 300px; }

/* Display Utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Context Banner for Follow-up Queries */
.context-banner-style {
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4a6f 100%);
    padding: 12px 18px;
    margin-bottom: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #8ab4f8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.context-banner-style.d-none {
    display: none !important;
}

/* Text Align */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Flex Utilities */
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }

/* Gap Utilities */
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.gap-20 { gap: 20px; }

/* Table Loading State */
.table-loading {
    text-align: center;
    color: var(--text-secondary);
}

/* Padding/Border Top Utilities */
.pt-12 { padding-top: 12px; }
.pt-15 { padding-top: 15px; }
.p-40 { padding: 40px; }
.border-top { border-top: 1px solid var(--border-default); }
.border-bottom { border-bottom: 1px solid var(--border-subtle); }
.border-left-blue { border-left: 3px solid var(--accent-blue); }
.border-left-red { border-left: 3px solid var(--accent-red); }
.border-left-green { border-left: 3px solid var(--accent-green); }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* White-space */
.white-space-nowrap { white-space: nowrap; }
.white-space-pre-wrap { white-space: pre-wrap; }

/* Margin utilities */
.m-2 { margin: 2px 0; }
.mb-2 { margin-bottom: 2px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mt-2 { margin-top: 2px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.ml-4 { margin-left: 4px; }
.ml-6 { margin-left: 6px; }
.ml-8 { margin-left: 8px; }

/* Padding utilities */
.p-8 { padding: 8px; }

/* Width 100% */
.w-full { width: 100%; }

/* Flex: 1 */
.flex-1 { flex: 1; }

