/* --- LocalLLM Hub - Light Professional Design System --- */
:root {
    --bg-app: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-secondary: #f1f5f9;
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    
    --sidebar-width: 260px;
    --header-height: 64px;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* --- Fixed Header --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-md);
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-text .badge-env {
    font-size: 0.7rem;
    font-weight: 600;
    background: #e0e7ff;
    color: #3730a3;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.brand-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    background-color: var(--success-light);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.btn-auth-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    transition: all 0.15s ease;
}

.btn-auth-status:hover {
    background-color: var(--bg-surface-secondary);
}

.btn-auth-status.authenticated {
    border-color: #bbf7d0;
    background-color: var(--success-light);
    color: var(--success);
}

/* --- Left Sidebar --- */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 14px;
    z-index: 90;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    padding: 8px 12px 4px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background-color: var(--bg-surface-secondary);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-info-card {
    background: var(--bg-surface-secondary);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-info-card strong {
    color: var(--text-main);
    display: block;
    margin-bottom: 2px;
}

/* --- Main Content Area --- */
.main-container {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    padding: 28px 32px 64px 32px;
    flex: 1;
    max-width: 1440px;
}

/* --- Section Titles --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

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

/* --- Metric Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-content h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-secondary);
    color: var(--primary);
}

/* --- Filter & Action Bar --- */
.toolbar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    width: 280px;
}

.search-input-wrapper svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
    background: var(--bg-surface);
    color: var(--text-main);
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: var(--border-focus);
}

.select-filter {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    background-color: var(--bg-surface);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

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

.btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
}

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

.btn-danger {
    background-color: var(--danger-light);
    color: var(--danger);
    border-color: #fecaca;
}

.btn-danger:hover {
    background-color: #fee2e2;
}

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

/* --- Models Table --- */
.table-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.custom-table th {
    background-color: var(--bg-surface-secondary);
    padding: 12px 18px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: #f8fafc;
}

.model-name-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.92rem;
}

.model-filename {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.badge-gpu {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.badge-cpu {
    background-color: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}

.badge-quant {
    background-color: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
    font-family: monospace;
}

.badge-format {
    background-color: #f3e8ff;
    color: #6b21a8;
    border-color: #e9d5ff;
    font-family: monospace;
}

.badge-instruct {
    background-color: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.actions-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Upload Area --- */
.upload-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
}

.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #eff6ff;
    color: var(--primary);
    margin-bottom: 16px;
}

.dropzone-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.dropzone-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Upload Preview Queue */
.upload-queue {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--bg-surface);
}

.upload-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.upload-parsed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    background: var(--bg-surface-secondary);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.8rem;
}

.upload-parsed-item strong {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    display: block;
}

.upload-progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.2s ease;
}

/* --- Android API Code Tab --- */
.code-box {
    background: #0f172a;
    color: #f8fafc;
    border-radius: var(--radius-md);
    padding: 20px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    position: relative;
    margin-top: 12px;
}

.btn-copy-code {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #334155;
    color: #ffffff;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-copy-code:hover {
    background: #475569;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    padding: 24px;
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

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

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

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    outline: none;
    color: var(--text-main);
}

.form-control:focus {
    border-color: var(--border-focus);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: #0f172a;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.25s ease forwards;
}

.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

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

/* View Sections switcher */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}
