/* ═══════════════════════════════════════════════════════════════
   Catvision IPTV — Admin Panel Shared Design System
   Included by all admin sub-pages loaded in the iframe.
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --bg:           #060B18;
    --bg-card:      #0D1529;
    --bg-input:     #111D35;
    --bg-hover:     #162040;
    --bg-table-head:#0F1A30;
    --border:       #1C2A4A;
    --border-light: #243352;
    --accent:       #38BDF8;
    --accent-dim:   #0EA5E9;
    --accent-glow:  rgba(56,189,248,0.1);
    --success:      #22C55E;
    --success-dim:  #16A34A;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --danger-dim:   #DC2626;
    --text:         #E2E8F0;
    --text-dim:     #8494B2;
    --text-muted:   #4A5A78;
    --radius:       8px;
    --radius-sm:    6px;
    --transition:   0.2s cubic-bezier(.4,0,.2,1);
    --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    padding: 24px 28px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h2 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
    margin: 0;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.2px;
    margin: 0;
}

/* ── Page Header ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.1px;
}

.card-description {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 18px;
    line-height: 1.6;
}

/* ── Labels & Form Groups ── */
label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

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

.form-group label {
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

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

/* ── Inputs ── */
input,
textarea,
select {
    width: 100%;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    padding: 0;
    border: none;
    background: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
    min-height: 90px;
    resize: vertical;
    font-family: var(--font);
}

input[type="file"] {
    color: var(--text-dim);
    font-size: 12px;
    padding: 8px 0;
    border: none;
    background: none;
    box-shadow: none;
}

/* ── Buttons ── */
button, .btn {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: 0.1px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    color: #fff;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(56,189,248,0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.primary, .btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    color: #fff;
}

.primary:hover, .btn-primary:hover {
    box-shadow: 0 4px 16px rgba(56,189,248,0.3);
}

.secondary, .btn-secondary {
    background: var(--bg-hover) !important;
    color: var(--text);
    border: 1px solid var(--border);
}

.secondary:hover, .btn-secondary:hover {
    background: var(--border) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.danger, .btn-danger {
    background: #DC2626 !important;
    color: #fff;
}

.danger:hover, .btn-danger:hover {
    background: #EF4444 !important;
    box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.success {
    background: #16A34A !important;
    color: #fff;
}

.success:hover {
    background: #22C55E !important;
    box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}

.warning {
    background: #D97706 !important;
    color: #fff;
}

.warning:hover {
    background: #F59E0B !important;
    box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}

.btn-small, .btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Small buttons with secondary class override */
.btn-small.secondary, .btn-sm.btn-secondary {
    background: var(--bg-hover) !important;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-small.danger, .btn-sm.btn-danger {
    background: #DC2626 !important;
    color: #fff;
}

/* ── Tables ── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-table-head);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
}

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

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: rgba(56,189,248,0.03);
}

.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

/* Enable modal when page script toggles `active` class. */
.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 500px;
    max-width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content::-webkit-scrollbar { width: 4px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.close, .close-btn, .modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: none !important;
    border: 1px solid var(--border) !important;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
    box-shadow: none !important;
}

.close:hover, .close-btn:hover, .modal-close:hover {
    background: var(--bg-hover) !important;
    color: #fff;
    border-color: var(--border-light) !important;
    transform: none;
    box-shadow: none !important;
}

/* ── Status Messages ── */
.status {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
}

.status.error {
    color: #F87171;
}

.status.success {
    color: #4ADE80;
}

/* ── Badges ── */
.badge, .status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.badge {
    background: var(--bg-hover);
    color: var(--text-dim);
    border: 1px solid var(--border);
    margin: 2px;
}

.badge.default { background: rgba(59,130,246,0.15); color: #60A5FA; border-color: rgba(59,130,246,0.2); }
.badge.custom { background: rgba(34,197,94,0.15); color: #4ADE80; border-color: rgba(34,197,94,0.2); }

.status-badge.enabled, .enabled {
    background: rgba(34,197,94,0.15);
    color: #4ADE80;
}

.status-badge.disabled, .disabled {
    background: rgba(107,114,128,0.15);
    color: #9CA3AF;
}

/* Priority badges */
.priority-badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.priority-normal { background: var(--bg-hover); color: var(--text-dim); }
.priority-important { background: rgba(245,158,11,0.15); color: #FBBF24; }
.priority-urgent { background: rgba(239,68,68,0.15); color: #F87171; }

/* Target badges */
.target-badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.target-badge.all { background: rgba(34,197,94,0.15); color: #4ADE80; }
.target-badge.group { background: rgba(139,92,246,0.15); color: #A78BFA; }
.target-badge.room { background: rgba(59,130,246,0.15); color: #60A5FA; }

/* ── Misc ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Stats Cards ── */
.stats {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Target Selector (Messages) ── */
.target-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.target-option {
    flex: 1;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
}

.target-option:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.target-option.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.target-option .icon { font-size: 22px; margin-bottom: 6px; }
.target-option .label { font-size: 12px; color: var(--text-dim); font-weight: 500; }

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

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

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

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

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

/* ── Time Boxes (Tools) ── */
.time-display { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }

.time-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    text-align: center;
    min-width: 200px;
}

.time-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.time-value {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

.time-date {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ── Category Items ── */
.category-list { margin-top: 12px; }

.category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    transition: all var(--transition);
}

.category-item:hover { background: var(--bg-hover); border-color: var(--border-light); }
.category-item.dragging { opacity: 0.5; border-color: var(--accent); }
.category-item.drag-over { border-color: var(--accent); background: var(--accent-glow); }

.drag-handle { cursor: grab; color: var(--text-muted); font-size: 18px; user-select: none; padding: 4px; }
.drag-handle:active { cursor: grabbing; }

.cat-priority {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    min-width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-name { flex: 1; font-size: 14px; color: var(--text); font-weight: 500; }
.cat-count { font-size: 12px; color: var(--text-muted); }
.cat-actions { display: flex; gap: 6px; }

/* ── Asset Row ── */
.asset-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}

.asset-row:last-child { border-bottom: none; }

.asset-row .label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    padding-top: 6px;
}

.asset-row .content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-img {
    max-width: 260px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

video {
    max-width: 260px;
    border-radius: var(--radius);
    background: var(--bg-card);
}

/* ── Progress bar ── */
.progress-container {
    margin-top: 16px;
    width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    display: none;
}

.progress-bar {
    height: 6px;
    background: linear-gradient(90deg, var(--accent), var(--accent-dim));
    width: 0%;
    transition: width 0.3s ease;
}

/* ── Online Status ── */
.online-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.online-status.online { background: rgba(34,197,94,0.12); color: #4ADE80; }
.online-status.offline { background: rgba(107,114,128,0.12); color: #9CA3AF; }

.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.online-dot.online {
    background: #22C55E;
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
    animation: pulse 2s infinite;
}

.online-dot.offline { background: #6B7280; }

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

/* ── Devices ── */
.devices-section { margin-top: 16px; }

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.device-info { flex: 1; }
.device-mac { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; color: var(--text); }
.device-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.device-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.heartbeat-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ── Preview Boxes ── */
.preview-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 12px;
    max-width: 400px;
}

.preview-title { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.preview-message { font-size: 13px; color: var(--text-dim); line-height: 1.6; white-space: pre-wrap; }

/* Message preview */
.message-preview {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.preview-content { color: var(--text-dim); white-space: pre-wrap; font-size: 13px; }

/* ── Inline Group ── */
.inline-group {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-group .form-group { margin-bottom: 0; flex: 1; min-width: 250px; }

/* ── Offset info ── */
.offset-info { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── Button Group ── */
.button-group { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ── Password Toggle ── */
.password-toggle { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.password-toggle input[type="checkbox"] { width: auto; }
.password-toggle label { margin: 0; font-size: 12px; font-weight: 400; }

/* ── Versions ── */
.versions { margin-top: 10px; font-size: 12px; color: var(--text-muted); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

body > * { animation: fadeIn 0.3s ease both; }
body > *:nth-child(2) { animation-delay: 0.05s; }
body > *:nth-child(3) { animation-delay: 0.1s; }
