/* common.css — iOS Dark Theme for VaraPetCam CS Dashboard */

:root {
    --bg: #1c1c1e;
    --bg2: #000;
    --card: #2c2c2e;
    --card-hover: #3a3a3c;
    --text: #f5f5f7;
    --dim: #8e8e93;
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --yellow: #ffd60a;
    --purple: #bf5af2;
    --border: #3a3a3c;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, system-ui, 'Helvetica Neue', sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navigation === */
.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.nav-link {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dim);
    white-space: nowrap;
    transition: background .2s, color .2s;
}

.nav-link:hover {
    background: var(--card);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background: var(--blue);
    color: #fff;
}

.nav-right {
    margin-left: auto;
    font-size: 12px;
    color: var(--dim);
    white-space: nowrap;
}

/* === Layout === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--dim);
    margin-bottom: 16px;
}

/* === Cards === */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 8px;
}

.card-title {
    font-size: 9px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 6px;
    font-weight: 700;
}

/* === Summary Cards (Fleet) === */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.summary-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 8px;
    text-align: center;
}

.summary-value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.summary-label {
    font-size: 12px;
    color: var(--dim);
    margin-top: 4px;
}

.summary-card.online .summary-value { color: var(--green); }
.summary-card.offline .summary-value { color: var(--red); }
.summary-card.warning .summary-value { color: var(--orange); }
.summary-card.info .summary-value { color: var(--blue); }

/* === Rows === */
.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.row .label { color: var(--dim); }
.row .value { font-weight: 600; }

/* === Device Grid === */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
}

.device-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: background .2s, transform .1s;
    border: 1px solid transparent;
}

.device-card:hover {
    background: var(--card-hover);
    transform: translateY(-1px);
    border-color: var(--border);
}

.device-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.device-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.device-dot.offline { background: var(--dim); }

.device-name {
    font-weight: 600;
    font-size: 14px;
}

.device-mac {
    font-size: 11px;
    color: var(--dim);
    font-family: 'SF Mono', monospace;
}

.device-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.metric {
    text-align: center;
}

.metric-value {
    font-size: 14px;
    font-weight: 600;
}

.metric-label {
    font-size: 10px;
    color: var(--dim);
    text-transform: uppercase;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-idle { background: #3a3a3c; color: var(--dim); }
.badge-ok { background: rgba(48,209,88,.2); color: var(--green); }
.badge-warn { background: rgba(255,159,10,.2); color: var(--orange); }
.badge-err { background: rgba(255,69,58,.2); color: var(--red); }
.badge-info { background: rgba(10,132,255,.2); color: var(--blue); }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s;
}

.btn:hover { opacity: .85; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-blue { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-secondary { background: var(--card-hover); color: var(--text); }

.btn-sm {
    padding: 3px 8px;
    font-size: 10px;
    border-radius: 6px;
}

.btn-block { display: block; width: 100%; text-align: center; }

/* === Tabs === */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color .2s;
}

.tab:hover { color: var(--text); }

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === Toggle === */
.toggle-group {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 3px;
    border-radius: 8px;
}

.toggle-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--dim);
    transition: background .2s, color .2s;
}

.toggle-btn.active {
    background: var(--blue);
    color: #fff;
}

/* === Slider === */
.slider-row {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 24px;
}

.slider-label {
    font-size: 10px;
    color: var(--dim);
    min-width: 52px;
}

.slider-input {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--blue);
    cursor: pointer;
}

.slider-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--blue);
    border: none;
    cursor: pointer;
}

.slider-input::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
}

.slider-value {
    font-size: 10px;
    font-weight: 600;
    min-width: 30px;
    text-align: right;
}

/* === Control Grid === */
.ctrl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.ctrl-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
}

.ctrl-item-title {
    font-size: 12px;
    color: var(--dim);
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* === Video === */
.video-wrap {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16/9;
    border-radius: var(--radius);
    overflow: hidden;
}

.video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,.7);
    color: var(--dim);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.video-label.live { color: var(--green); }

.video-overlay-btn {
    position: absolute;
    bottom: 8px;
    background: rgba(0,0,0,.7);
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.video-overlay-btn.right { right: 8px; }
.video-overlay-btn.left { left: 8px; }

/* === Timeline === */
.timeline {
    list-style: none;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.timeline-time {
    color: var(--dim);
    font-size: 11px;
    min-width: 60px;
    font-family: 'SF Mono', monospace;
}

.timeline-text { flex: 1; }

/* === Event List === */
.event-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background .2s;
}

.event-row:hover { background: var(--card-hover); }

.event-thumb {
    width: 80px;
    height: 45px;
    background: var(--bg);
    border-radius: 4px;
    flex-shrink: 0;
    overflow: hidden;
}

.event-thumb video,
.event-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-info { flex: 1; }
.event-title { font-size: 13px; font-weight: 600; }
.event-meta { font-size: 11px; color: var(--dim); }

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
    transition: width .3s;
}

.progress-fill.ok { background: var(--green); }
.progress-fill.err { background: var(--red); }

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    animation: toast-in .3s ease;
    max-width: 360px;
}

.toast-ok { background: rgba(48,209,88,.9); color: #fff; }
.toast-err { background: rgba(255,69,58,.9); color: #fff; }
.toast-info { background: rgba(10,132,255,.9); color: #fff; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Spinner === */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === Log === */
.log-area {
    background: #111;
    border-radius: var(--radius-sm);
    padding: 10px;
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    max-height: 250px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--dim);
}

/* === iOS Toggle Switch === */
.ios-toggle {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}
.ios-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.ios-toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 9px;
    transition: background .25s;
}
.ios-toggle .slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform .25s;
}
.ios-toggle input:checked + .slider {
    background: var(--green);
}
.ios-toggle input:checked + .slider::before {
    transform: translateX(16px);
}

/* === Section Label (replaces card-title in grouped controls) === */
.section-label {
    font-size: 9px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 700;
    padding: 6px 0 3px;
}

/* === Compact control row === */
.ctrl-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 11px;
}
.ctrl-row .label {
    color: var(--dim);
    font-size: 10px;
    min-width: 40px;
}

/* === Responsive === */
@media (max-width: 600px) {
    .container { padding: 8px; }
    .device-grid { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .ctrl-grid { grid-template-columns: 1fr; }
    .device-metrics { grid-template-columns: repeat(2, 1fr); }
    .nav { padding: 8px 12px; gap: 8px; }
    .nav-link { padding: 4px 8px; font-size: 12px; }
}
