/* Chicane V3 Theme System */
:root {
    --main: #3b82f6;
    --radius-sm: 6px;
}

[data-theme="dark"], :root {
    --bg: #0f1117;
    --surface-1: #161b22;
    --surface-2: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-ghost: #484f58;
}

[data-theme="light"] {
    --bg: #f6f8fa;
    --surface-1: #ffffff;
    --surface-2: #f0f2f5;
    --border: #d0d7de;
    --text: #1f2937;
    --text-muted: #57606a;
    --text-ghost: #8b949e;
}

/* Status colors */
:root {
    --status-online: #00c98e;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-info: #3b82f6;
    --status-offline: #8b949e;
    --status-purple: #8b5cf6;
}

/* Base styling */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Noto Sans, Helvetica, Arial, sans-serif;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    margin: 0;
}

/* Status dots */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--status-online); }
.status-dot.offline { background: var(--status-offline); }
.status-dot.downloading { background: var(--status-info); }
.status-dot.error { background: var(--status-error); }
.status-dot.warning { background: var(--status-warning); }

/* Activity pulse animation */
.activity-pulse {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--status-online);
    animation: pulse-anim 1.5s ease-in-out infinite;
}
@keyframes pulse-anim {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

/* Monospace for protocol data */
.mono { font-family: 'Cascadia Code', Consolas, monospace; font-size: 12px; }

/* Labels/hints */
.text-muted { color: var(--text-muted) !important; }
.text-ghost { color: var(--text-ghost) !important; font-size: 11px !important; }

/* Section titles */
.section-title {
    font-size: 13px; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

/* Scrollbar styling for dark mode */
[data-theme="dark"] ::-webkit-scrollbar { width: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--text-ghost); }

/* ==================== */
/* Chicane V3 Components */
/* ==================== */

/* Buttons */
.btn { padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-family: inherit; line-height: 1.4; }
.btn:hover { background: var(--surface-1); }
.btn-primary { background: var(--main); color: #fff; border-color: var(--main); }
.btn-primary:hover { background: color-mix(in srgb, var(--main), black 15%); }
.btn-danger { background: var(--status-error); color: #fff; border-color: var(--status-error); }
.btn-danger:hover { background: color-mix(in srgb, var(--status-error), black 15%); }
.btn-default { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Form */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: 13px; font-family: inherit; box-sizing: border-box; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--main); box-shadow: 0 0 0 2px color-mix(in srgb, var(--main), transparent 75%); }
input::placeholder { color: var(--text-ghost); }
input[type="checkbox"] { width: auto; }
input[type="color"] { padding: 2px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:hover td { background: var(--surface-2); }
.data-table tr { cursor: pointer; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.badge-success { background: color-mix(in srgb, var(--status-online), transparent 85%); color: var(--status-online); }
.badge-error { background: color-mix(in srgb, var(--status-error), transparent 85%); color: var(--status-error); }
.badge-warning { background: color-mix(in srgb, var(--status-warning), transparent 85%); color: var(--status-warning); }
.badge-info { background: color-mix(in srgb, var(--status-info), transparent 85%); color: var(--status-info); }
.badge-default { background: var(--surface-2); color: var(--text-muted); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 16px; font-size: 13px; cursor: pointer; border: none; background: transparent; color: var(--text-muted); border-bottom: 2px solid transparent; transition: all 0.15s; font-family: inherit; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--main); border-bottom-color: var(--main); }

/* Cards */
.v3-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; }

/* Alerts */
.alert { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 12px; border: 1px solid; }
.alert-error { background: color-mix(in srgb, var(--status-error), transparent 90%); border-color: var(--status-error); color: var(--status-error); }
.alert-success { background: color-mix(in srgb, var(--status-online), transparent 90%); border-color: var(--status-online); color: var(--status-online); }
.alert-warning { background: color-mix(in srgb, var(--status-warning), transparent 90%); border-color: var(--status-warning); color: var(--status-warning); }
.alert-info { background: color-mix(in srgb, var(--status-info), transparent 90%); border-color: var(--status-info); color: var(--status-info); }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); min-width: 400px; max-width: 600px; max-height: 80vh; display: flex; flex-direction: column; }
.modal-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; }
.modal-header button { background: none; border: none; color: var(--text-ghost); cursor: pointer; font-size: 18px; }
.modal-body { padding: 16px; flex: 1; overflow-y: auto; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Nav links */
.nav-link { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13px; color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm); transition: all 0.12s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: color-mix(in srgb, var(--main), transparent 85%); color: var(--main); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

/* Spinner */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--main); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress bar */
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--main); transition: width 0.3s; }
.progress-bar-indeterminate .progress-bar-fill { width: 30%; animation: progress-indeterminate 1.5s infinite; }
@keyframes progress-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }

/* Select dropdown */
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* Toast container */
.toast-container { position: fixed; bottom: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column-reverse; gap: 8px; }
.toast { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 12px; color: var(--text); box-shadow: 0 4px 12px rgba(0,0,0,0.3); display: flex; align-items: center; gap: 8px; animation: toast-in 0.3s; min-width: 250px; }
.toast-success { border-left: 3px solid var(--status-online); }
.toast-error { border-left: 3px solid var(--status-error); }
.toast-warning { border-left: 3px solid var(--status-warning); }
.toast-info { border-left: 3px solid var(--status-info); }
@keyframes toast-in { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* Grid layout helpers */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; }
.stat-card .stat-value { font-size: 24px; font-weight: 600; color: var(--text); }
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* File drop zone */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 24px; text-align: center; color: var(--text-ghost); cursor: pointer; transition: all 0.15s; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--main); background: color-mix(in srgb, var(--main), transparent 95%); color: var(--text-muted); }

/* Two-column settings form: label | input pairs. Used across reseller/company self-service
   and admin pages — keeps short numeric / boolean fields aligned in a tidy grid instead of
   wrapping inline. Cells own their vertical padding so adjacent rows don't bunch up. */
.settings-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 12px;
    row-gap: 8px;
    align-items: center;
}
.settings-grid > label { margin: 0; font-size: 13px; color: var(--text); }
.settings-grid > input,
.settings-grid > select,
.settings-grid > textarea { margin: 0; }

/* Report Gantt bar activity colours */
.gantt-drive { background: #F44336; }
.gantt-work { background: #FF9800; }
.gantt-available { background: #2196F3; }
.gantt-rest { background: #4CAF50; }
.gantt-assumed-rest { background: #5FBFA9; }
.gantt-poa { background: #9C27B0; }
.gantt-drive-oos { background: #795548; }

/* Report RAG badges */
.rag-red { background: rgba(239,68,68,0.15); color: var(--status-error); }
.rag-amber { background: rgba(245,158,11,0.15); color: var(--status-warning); }
.rag-green { background: rgba(0,201,142,0.15); color: var(--status-online); }
