:root {
    --pd-bg: #0b0f19;
    --pd-surface: #111827;
    --pd-surface-card: #162032;
    --pd-surface-hover: #1f2d45;
    --pd-border: rgba(255, 255, 255, 0.08);
    --pd-border-focus: #0ea5e9;
    --pd-primary: #0ea5e9;
    --pd-primary-hover: #0284c7;
    --pd-success: #10b981;
    --pd-warning: #f59e0b;
    --pd-danger: #ef4444;
    --pd-text-main: #f8fafc;
    --pd-text-muted: #94a3b8;
    --pd-radius: 12px;
    --pd-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--pd-bg);
    color: var(--pd-text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Layout Estrutural */
.pd-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.pd-sidebar {
    width: 260px;
    background: var(--pd-surface);
    border-right: 1px solid var(--pd-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.pd-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--pd-border);
}

.pd-brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.pd-brand-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
    color: #fff;
}

.pd-brand-text span {
    font-size: 0.75rem;
    color: var(--pd-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pd-nav {
    padding: 20px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pd-nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--pd-text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.pd-nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.pd-nav-link:hover {
    background: var(--pd-surface-hover);
    color: var(--pd-text-main);
}

.pd-nav-link.active {
    background: rgba(14, 165, 233, 0.15);
    color: var(--pd-primary);
    font-weight: 600;
}

.pd-sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--pd-border);
}

/* Área Principal */
.pd-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Topbar */
.pd-topbar {
    height: 70px;
    background: var(--pd-surface);
    border-bottom: 1px solid var(--pd-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.pd-quick-connect {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pd-bg);
    border: 1px solid var(--pd-border);
    border-radius: 8px;
    padding: 6px 12px;
    max-width: 380px;
    width: 100%;
}

.pd-quick-connect input {
    background: transparent;
    border: none;
    color: #fff;
    outline: none;
    font-size: 0.9rem;
    width: 100%;
}

.pd-quick-connect input::placeholder {
    color: var(--pd-text-muted);
}

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

.pd-user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--pd-surface-card);
    border: 1px solid var(--pd-border);
    border-radius: 20px;
}

.pd-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
}

/* Conteúdo */
.pd-content {
    padding: 28px;
}

/* Cards de Métricas */
.pd-stat-card {
    background: var(--pd-surface-card);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.pd-stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(14, 165, 233, 0.4);
}

.pd-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.pd-stat-icon.primary { background: rgba(14, 165, 233, 0.15); color: var(--pd-primary); }
.pd-stat-icon.success { background: rgba(16, 185, 129, 0.15); color: var(--pd-success); }
.pd-stat-icon.warning { background: rgba(245, 158, 11, 0.15); color: var(--pd-warning); }
.pd-stat-icon.danger { background: rgba(239, 68, 68, 0.15); color: var(--pd-danger); }

.pd-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin: 4px 0;
}

.pd-stat-label {
    color: var(--pd-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Painel e Tabelas */
.pd-card {
    background: var(--pd-surface-card);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    overflow: hidden;
    box-shadow: var(--pd-shadow);
}

.pd-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--pd-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pd-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.pd-card-body {
    padding: 24px;
}

/* Custom DataTables para tema escuro */
table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    color: var(--pd-text-main) !important;
}

table.dataTable thead th {
    background-color: var(--pd-surface) !important;
    color: var(--pd-text-muted) !important;
    border-bottom: 1px solid var(--pd-border) !important;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px !important;
}

table.dataTable tbody tr {
    background-color: transparent !important;
    transition: background 0.15s ease;
}

table.dataTable tbody tr:hover {
    background-color: var(--pd-surface-hover) !important;
}

table.dataTable tbody td {
    padding: 14px 16px !important;
    border-bottom: 1px solid var(--pd-border) !important;
    vertical-align: middle;
    font-size: 0.95rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--pd-bg) !important;
    border: 1px solid var(--pd-border) !important;
    color: #fff !important;
    border-radius: 6px;
    padding: 6px 12px;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--pd-text-muted) !important;
    padding-top: 16px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--pd-text-main) !important;
    background: var(--pd-surface) !important;
    border: 1px solid var(--pd-border) !important;
    border-radius: 6px !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--pd-primary) !important;
    color: #fff !important;
    border-color: var(--pd-primary) !important;
}

/* Status Badges e Pulsos */
.pd-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.pd-status-pill.online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--pd-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.pd-status-pill.busy {
    background: rgba(245, 158, 11, 0.15);
    color: var(--pd-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.pd-status-pill.offline {
    background: rgba(148, 163, 184, 0.15);
    color: var(--pd-text-muted);
    border: 1px solid var(--pd-border);
}

.pd-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.pd-status-pill.online .pd-pulse-dot {
    background: var(--pd-success);
    box-shadow: 0 0 8px var(--pd-success);
}

.pd-status-pill.busy .pd-pulse-dot {
    background: var(--pd-warning);
    box-shadow: 0 0 8px var(--pd-warning);
}

.pd-status-pill.offline .pd-pulse-dot {
    background: var(--pd-text-muted);
}

/* Botões do Sistema */
.btn-pd-primary {
    background: var(--pd-primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
}

.btn-pd-primary:hover {
    background: var(--pd-primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

.btn-pd-secondary {
    background: var(--pd-surface-hover);
    color: var(--pd-text-main);
    border: 1px solid var(--pd-border);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
}

.btn-pd-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ============================================================ */
/* INTERFACE DE CONTROLE REMOTO (Sessao.php / TV Box Remote)     */
/* ============================================================ */
.pd-session-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 120px);
}

.pd-screen-area {
    flex: 1;
    background: #000;
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: var(--pd-shadow);
}

.pd-screen-toolbar {
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(8px);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--pd-border);
    z-index: 10;
}

.pd-screen-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #050811;
    cursor: crosshair;
}

.pd-screen-viewport video,
.pd-screen-viewport canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Controle Remoto Físico Virtual (Sidebar de Controle) */
.pd-remote-control {
    width: 320px;
    background: var(--pd-surface-card);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: var(--pd-shadow);
    overflow-y: auto;
}

.pd-remote-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pd-border);
}

.pd-remote-header h4 {
    margin: 0;
    font-size: 1.05rem;
    color: #fff;
}

.pd-remote-header span {
    font-size: 0.75rem;
    color: var(--pd-text-muted);
}

/* D-PAD Circular */
.pd-dpad {
    position: relative;
    width: 200px;
    height: 200px;
    background: #111827;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    margin: 15px auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.05);
}

.pd-dpad-btn {
    position: absolute;
    background: #1e293b;
    border: none;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pd-dpad-btn:hover {
    background: #334155;
    color: #fff;
}

.pd-dpad-btn:active {
    background: var(--pd-primary);
    color: #fff;
    transform: scale(0.95);
}

.pd-dpad-up {
    top: 8px;
    left: 70px;
    width: 60px;
    height: 48px;
    border-radius: 20px 20px 6px 6px;
}

.pd-dpad-down {
    bottom: 8px;
    left: 70px;
    width: 60px;
    height: 48px;
    border-radius: 6px 6px 20px 20px;
}

.pd-dpad-left {
    top: 70px;
    left: 8px;
    width: 48px;
    height: 60px;
    border-radius: 20px 6px 6px 20px;
}

.pd-dpad-right {
    top: 70px;
    right: 8px;
    width: 48px;
    height: 60px;
    border-radius: 6px 20px 20px 6px;
}

.pd-dpad-ok {
    top: 70px;
    left: 70px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

.pd-dpad-ok:hover {
    background: linear-gradient(135deg, #0369a1, #0284c7);
}

.pd-dpad-ok:active {
    transform: scale(0.92);
}

/* Botões do Controle de TV */
.pd-remote-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.pd-remote-btn {
    background: #1e293b;
    border: 1px solid var(--pd-border);
    color: #e2e8f0;
    padding: 12px 8px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pd-remote-btn i {
    font-size: 1.1rem;
    color: var(--pd-primary);
}

.pd-remote-btn:hover {
    background: #334155;
    border-color: rgba(14, 165, 233, 0.4);
}

.pd-remote-btn:active {
    transform: scale(0.95);
    background: var(--pd-primary);
}

.pd-remote-btn:active i {
    color: #fff;
}

.pd-remote-btn.power {
    color: #f87171;
}

.pd-remote-btn.power i {
    color: #ef4444;
}

/* Envio de Texto Rápido para a TV */
.pd-text-sender {
    background: #111827;
    border: 1px solid var(--pd-border);
    border-radius: 8px;
    padding: 12px;
}

.pd-text-sender label {
    font-size: 0.75rem;
    color: var(--pd-text-muted);
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
    text-transform: uppercase;
}

/* Visual do painel: grafite, contraste e componentes consistentes. */
:root {
    --pd-bg: #15171e; --pd-surface: #101218; --pd-surface-card: #20232c;
    --pd-surface-hover: #292e39; --pd-border: #343945; --pd-primary: #168cdd;
    --pd-primary-hover: #0877c4; --pd-text-muted: #a8b1c2;
    --pd-shadow: 0 8px 24px rgba(0,0,0,.12);
}
body { color: #eef1f6; }
.pd-sidebar { width: 250px; }
.pd-brand { padding: 24px 22px; }
.pd-brand-logo { background: #168cdd; box-shadow: none; }
.pd-brand-text span { color: #9aabba; }
.pd-nav-link { color: #c0c7d3; border-radius: 8px; }
.pd-nav-link.active { background: var(--pd-primary); color: white; }
.pd-topbar { min-height: 72px; height: auto; padding: 14px 28px; gap: 18px; background: #1b1e26; }
.pd-content { padding: 32px; }
.pd-card, .pd-stat-card { border: 1px solid #292e38; box-shadow: var(--pd-shadow); }
.pd-stat-card { min-height: 150px; }
.pd-stat-card:hover { transform: none; }
.pd-stat-icon { margin-bottom: 14px; }
.pd-card-header { border-color: #353a45; }
.text-muted { color: #aab4c4 !important; }
.pd-card .table, .pd-card .table-dark, .pd-card table.dataTable {
    --bs-table-color: #e8ecf3; --bs-table-bg: transparent; --bs-table-border-color: #373d49;
    --bs-table-striped-color: #e8ecf3; --bs-table-striped-bg: rgba(255,255,255,.025);
    --bs-table-hover-color: #fff; --bs-table-hover-bg: #292e38; color: #e8ecf3 !important;
}
.pd-card .table > :not(caption) > * > * { color: inherit; background-color: transparent; border-color: #373d49; box-shadow: none; vertical-align: middle; }
.pd-card .table thead th, table.dataTable thead th { background: #242832 !important; color: #aeb8c8 !important; font-size: .75rem; letter-spacing: .04em; }
.pd-card .table tbody tr:hover > * { background-color: #292e38; }
.pd-card .table tbody td { padding: 14px 16px; }
.form-control, .form-select, .dataTables_wrapper input, .dataTables_wrapper select { background-color: #191c24 !important; border: 1px solid #3b414e !important; color: #f5f7fb !important; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(22,140,221,.18); border-color: #168cdd !important; }
.form-control::placeholder { color: #8f99a9; }
.pd-quick-connect { background: #151820; }
.pd-user-badge { background: #242832; border-radius: 10px; }
.pd-user-avatar { background: #168cdd; }
.modal-content, .swal2-popup { background: #242832 !important; color: #eef1f6 !important; border: 1px solid #414854 !important; border-radius: 14px !important; }
.modal-header, .modal-footer { border-color: #3b414e !important; }
.modal { overflow-y: auto; }
.modal-backdrop { z-index: 1040; }
.modal.show { z-index: 1055; }
.dropdown-menu { background: #252a34; border: 1px solid #424a58; }
.pd-session-container { min-height: 600px; }
.pd-screen-area { min-width: 0; }
.pd-remote-control { flex-shrink: 0; }
@media (max-width: 900px) {
    .pd-sidebar { width: 74px; }
    .pd-brand { justify-content: center; padding: 18px 8px; }
    .pd-brand-text, .pd-nav-link span, .pd-sidebar-footer { display: none; }
    .pd-nav-link { justify-content: center; padding: 13px 8px; }
    .pd-content { padding: 22px 16px; }
    .pd-topbar { flex-wrap: wrap; padding: 12px 16px; }
    .pd-quick-connect { max-width: none; }
    .pd-session-container { height: auto; flex-direction: column; }
    .pd-screen-area { min-height: 420px; }
    .pd-remote-control { width: 100%; }
}
@media (max-width: 540px) {
    .pd-topbar-actions { width: 100%; justify-content: space-between; }
    .pd-content > .d-flex.justify-content-between { flex-wrap: wrap; gap: 16px; }
    .pd-screen-toolbar { flex-wrap: wrap; gap: 10px; }
    .pd-quick-connect input { min-width: 0; }
}
