/* QBasket Training Panel — Cucos Design */
:root {
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: #D1FAE5;
    --bg: #F9FAFB;
    --surface: #FFFFFF;
    --surface-alt: #F3F4F6;
    --text: #111827;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --blue: #3B82F6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* --- Header --- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

header .logo {
    height: 28px;
    width: auto;
}

.badge {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-idle { background: var(--surface-alt); color: var(--text-muted); }
.badge-training { background: var(--primary-light); color: var(--primary-dark); animation: pulse 2s infinite; }
.badge-online { background: var(--primary-light); color: var(--primary-dark); }
.badge-offline { background: #FEE2E2; color: #991B1B; }
.badge-error { background: #FEE2E2; color: #991B1B; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Navigation --- */
nav {
    display: flex;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    overflow-x: auto;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* --- Views --- */
.view { display: none; padding: 20px 24px; max-width: 1200px; margin: 0 auto; }
.view.active { display: block; }

/* --- Cards --- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card h3, .card h4 {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card.wide { grid-column: 1 / -1; }

.metric {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Charts --- */
.chart-container {
    position: relative;
    height: 300px;
}

/* --- Log Box --- */
.log-box {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-muted);
}

/* --- Image Gallery --- */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.image-gallery img {
    width: 100%;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}
.image-gallery img:hover { transform: scale(1.02); box-shadow: var(--shadow); }

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 250px;
}
th {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: var(--surface-alt);
    position: sticky;
    top: 0;
}
tr:hover { background: var(--surface-alt); }
tr { cursor: pointer; }
.sortable { cursor: pointer; }
.sortable:hover { color: var(--primary-dark); }

/* --- Buttons --- */
.btn {
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }

.actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Forms --- */
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-weight: 500;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.filter-input {
    flex: 1;
    min-width: 180px;
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
}
.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.filter-select {
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8rem;
}

/* --- Parameters Grid --- */
.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 6px;
}
.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: var(--surface-alt);
    border-radius: 4px;
    font-size: 0.8rem;
    overflow: hidden;
}
.param-label { color: var(--text-muted); white-space: nowrap; }
.param-value { font-weight: 600; color: var(--primary-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 8px; }

/* --- Metric Colors --- */
.metric-good { color: var(--success); }
.metric-ok { color: var(--warning); }
.metric-bad { color: var(--danger); }

/* --- Sync Button --- */
.btn-sync {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 100;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}
.btn-sync:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-sync.syncing { animation: pulse 1s infinite; pointer-events: none; }

/* --- Login --- */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 340px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.login-box .logo { height: 36px; margin-bottom: 16px; }

/* --- Dropzone --- */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}
.dropzone a { color: var(--primary); text-decoration: underline; }

/* --- Utilities --- */
.hidden { display: none !important; }
h2 { margin-bottom: 14px; font-size: 1.1rem; font-weight: 600; color: var(--text); }

/* --- Responsive --- */
@media (max-width: 640px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    header { padding: 10px 16px; }
    nav { padding: 0 16px; }
    .view { padding: 16px; }
    .metric { font-size: 1.1rem; }
}
