/* ============================================================
   IPTV Manager — Custom Stylesheet
   Stack: Bootstrap 5.3 + Custom CSS
   Font: Inter (Google Fonts)
   ============================================================ */

/* ── Variáveis de Design ────────────────────────────────────── */
:root {
    --clr-bg:            #0d1117;
    --clr-bg-secondary:  #161b22;
    --clr-bg-card:       #1c2333;
    --clr-border:        rgba(255, 255, 255, 0.08);
    --clr-text:          #e6edf3;
    --clr-text-muted:    #8b949e;
    --clr-primary:       #1f6feb;
    --clr-primary-hover: #388bfd;
    --clr-success:       #3fb950;
    --clr-warning:       #d29922;
    --clr-danger:        #f85149;
    --clr-info:          #58a6ff;
    --clr-navbar:        #010409;
    --radius-card:       12px;
    --radius-btn:        8px;
    --shadow-card:       0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow:       0 0 20px rgba(31, 111, 235, 0.15);
    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main:         'Inter', system-ui, -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background-color: var(--clr-bg);
    color: var(--clr-text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar personalizada ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--clr-bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */
.login-body {
    background: radial-gradient(ellipse at 20% 50%, rgba(31,111,235,.12) 0%, transparent 55%),
                radial-gradient(ellipse at 80% 20%, rgba(63,185,80,.06) 0%, transparent 55%),
                var(--clr-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
}

.login-wrapper {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
    z-index: 2;
}

.login-card {
    background: var(--clr-bg-card);
    border: 1px solid var(--clr-border);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow-card), var(--shadow-glow);
    backdrop-filter: blur(12px);
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-icon {
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}

.login-icon img {
    width: 72px; height: 72px;
    object-fit: contain;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--clr-text);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--clr-text-muted);
    font-size: 0.875rem;
    margin-bottom: 0;
}

.btn-login {
    background: linear-gradient(135deg, var(--clr-primary), #388bfd);
    border: none;
    border-radius: var(--radius-btn);
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(31,111,235,.35);
}
.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(31,111,235,.5);
    background: linear-gradient(135deg, #388bfd, #58a6ff);
}

/* Partículas decorativas */
.login-particles {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none; z-index: 1;
    overflow: hidden;
}
.login-particles span {
    position: absolute;
    width: 3px; height: 3px;
    background: var(--clr-primary);
    border-radius: 50%;
    opacity: .4;
    animation: float linear infinite;
}
.login-particles span:nth-child(1)  { left:10%; top:80%; animation-duration:12s; animation-delay:0s; }
.login-particles span:nth-child(2)  { left:30%; top:60%; animation-duration:15s; animation-delay:2s; width:5px; height:5px; opacity:.2; }
.login-particles span:nth-child(3)  { left:55%; top:90%; animation-duration:10s; animation-delay:4s; }
.login-particles span:nth-child(4)  { left:70%; top:40%; animation-duration:18s; animation-delay:1s; width:4px; height:4px; }
.login-particles span:nth-child(5)  { left:85%; top:70%; animation-duration:13s; animation-delay:3s; }
.login-particles span:nth-child(6)  { left:45%; top:20%; animation-duration:16s; animation-delay:5s; width:6px; height:6px; opacity:.15; }

@keyframes float {
    0%   { transform: translateY(0) rotate(0deg); opacity: .4; }
    100% { transform: translateY(-120vh) rotate(360deg); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════════════════════════ */
.navbar-custom {
    background: var(--clr-navbar) !important;
    border-bottom: 1px solid var(--clr-border);
    padding: 0.6rem 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,.4);
}

.navbar-brand {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--clr-text) !important;
}

/* ══════════════════════════════════════════════════════════════
   STAT CARDS (Cards financeiros)
══════════════════════════════════════════════════════════════ */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-card);
    border: 1px solid transparent;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 120px; height: 120px;
    border-radius: 50%;
    opacity: .05;
    transform: translate(30%, -30%);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.stat-card--success {
    background: linear-gradient(135deg, rgba(63,185,80,.15), rgba(63,185,80,.05));
    border-color: rgba(63,185,80,.25);
}
.stat-card--success .stat-card__icon { color: var(--clr-success); }
.stat-card--success::before { background: var(--clr-success); }

.stat-card--danger {
    background: linear-gradient(135deg, rgba(248,81,73,.15), rgba(248,81,73,.05));
    border-color: rgba(248,81,73,.25);
}
.stat-card--danger .stat-card__icon { color: var(--clr-danger); }
.stat-card--danger::before { background: var(--clr-danger); }

.stat-card--info {
    background: linear-gradient(135deg, rgba(31,111,235,.15), rgba(31,111,235,.05));
    border-color: rgba(31,111,235,.25);
}
.stat-card--info .stat-card__icon { color: var(--clr-info); }
.stat-card--info::before { background: var(--clr-info); }

.stat-card--warning {
    background: linear-gradient(135deg, rgba(210,153,34,.15), rgba(210,153,34,.05));
    border-color: rgba(210,153,34,.25);
}
.stat-card--warning .stat-card__icon { color: var(--clr-warning); }
.stat-card--warning::before { background: var(--clr-warning); }

.stat-card__icon {
    font-size: 2.25rem;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px currentColor);
}

.stat-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.stat-card__label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--clr-text);
    line-height: 1;
    letter-spacing: -1px;
}

.stat-card__sub {
    font-size: 0.75rem;
    color: var(--clr-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════════
   CARD PANEL (Cards gerais)
══════════════════════════════════════════════════════════════ */
.card-panel {
    background: var(--clr-bg-card) !important;
    border: 1px solid var(--clr-border) !important;
    border-radius: var(--radius-card) !important;
    box-shadow: var(--shadow-card);
    color: var(--clr-text) !important;
}

.card-panel .card-header {
    background: rgba(255,255,255,.03) !important;
    border-bottom: 1px solid var(--clr-border) !important;
    padding: 1rem 1.25rem;
    color: var(--clr-text);
}

/* ── Filtro de Status (btn-group radio) ── */
#filtro-status-group .btn {
    font-size: 0.78rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0 !important;
    flex: 1;
    white-space: nowrap;
}
#filtro-status-group .btn:first-of-type { border-radius: 8px 0 0 8px !important; }
#filtro-status-group .btn:last-of-type  { border-radius: 0 8px 8px 0 !important; }

/* Estado ATIVO: Todos */
#status-todos:checked + label {
    background: rgba(255,255,255,.08) !important;
    color: var(--clr-text) !important;
    border-color: rgba(255,255,255,.2) !important;
}
/* Estado ATIVO: Ativos */
#status-ativos:checked + label {
    background: rgba(63,185,80,.2) !important;
    color: var(--clr-success) !important;
    border-color: rgba(63,185,80,.5) !important;
    box-shadow: 0 0 0 1px rgba(63,185,80,.3);
}
/* Estado ATIVO: Vencidos */
#status-vencidos:checked + label {
    background: rgba(248,81,73,.2) !important;
    color: var(--clr-danger) !important;
    border-color: rgba(248,81,73,.5) !important;
    box-shadow: 0 0 0 1px rgba(248,81,73,.3);
}

/* ══════════════════════════════════════════════════════════════
   TABELA CUSTOMIZADA
══════════════════════════════════════════════════════════════ */
.table-custom {
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--clr-text) !important;
    --bs-table-hover-bg: rgba(255,255,255,.04) !important;
    --bs-table-hover-color: var(--clr-text) !important;
    color: var(--clr-text);
    font-size: 0.875rem;
    background-color: transparent !important;
}

.table-custom > :not(caption) > * > * {
    background-color: transparent !important;
    color: var(--clr-text) !important;
}

.table-custom thead th {
    background: rgba(255,255,255,.04) !important;
    border-bottom: 1px solid var(--clr-border) !important;
    color: var(--clr-text-muted) !important;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.table-custom tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.04) !important;
    vertical-align: middle;
    background-color: transparent !important;
    color: var(--clr-text) !important;
}

.table-custom tbody tr:last-child td { border-bottom: none !important; }

.table-custom tbody tr:hover td,
.table-custom tbody tr:hover > * {
    background: rgba(255,255,255,.04) !important;
    color: var(--clr-text) !important;
}

.table-custom a {
    color: var(--clr-text) !important;
}

.table-custom a:hover {
    color: var(--clr-text) !important;
    opacity: .85;
}

/* ── Status row tinting ── */
.cliente-row.status-expirou td:first-child {
    border-left: 3px solid var(--clr-danger);
}
.cliente-row.status-a_vencer td:first-child {
    border-left: 3px solid var(--clr-warning);
}
.cliente-row.status-ativo td:first-child {
    border-left: 3px solid var(--clr-success);
}

/* ── Dias Badge ── */
.dias-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    min-width: 44px;
}

.dias-badge--ativo    { background: rgba(63,185,80,.15);  color: var(--clr-success); border: 1px solid rgba(63,185,80,.3); }
.dias-badge--a_vencer { background: rgba(210,153,34,.15); color: var(--clr-warning); border: 1px solid rgba(210,153,34,.3); }
.dias-badge--expirou  { background: rgba(248,81,73,.15);  color: var(--clr-danger);  border: 1px solid rgba(248,81,73,.3); }

/* ── Botões de ação ── */
.btn-action {
    border-radius: 6px !important;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.btn-action:hover { transform: translateY(-1px); }

/* ══════════════════════════════════════════════════════════════
   MODAL CUSTOMIZADO
══════════════════════════════════════════════════════════════ */
.modal-custom {
    background: var(--clr-bg-secondary);
    border: 1px solid var(--clr-border);
    border-radius: 16px;
    color: var(--clr-text);
    box-shadow: 0 24px 48px rgba(0,0,0,.6);
}

.modal-custom .modal-header {
    border-bottom: 1px solid var(--clr-border);
    padding: 1.25rem 1.5rem;
    background: rgba(255,255,255,.02);
    border-radius: 16px 16px 0 0;
}

.modal-custom .modal-title { color: var(--clr-text); }

.modal-custom .modal-body { padding: 1.5rem; }

.modal-custom .modal-footer {
    border-top: 1px solid var(--clr-border);
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,.02);
    border-radius: 0 0 16px 16px;
}

.modal-backdrop { backdrop-filter: blur(4px); }

/* ══════════════════════════════════════════════════════════════
   FORM CONTROLS (Dark Mode)
══════════════════════════════════════════════════════════════ */
.form-control,
.form-select,
.input-group-text {
    background-color: rgba(255,255,255,.05) !important;
    border-color: var(--clr-border) !important;
    color: var(--clr-text) !important;
    border-radius: var(--radius-btn) !important;
    transition: var(--transition-smooth);
}

.form-select option {
    background-color: var(--clr-bg-secondary) !important;
    color: var(--clr-text) !important;
}

.form-control:focus,
.form-select:focus {
    background-color: rgba(255,255,255,.08) !important;
    border-color: var(--clr-primary) !important;
    box-shadow: 0 0 0 3px rgba(31,111,235,.2) !important;
    color: var(--clr-text) !important;
}

.form-control::placeholder { color: var(--clr-text-muted) !important; opacity: .7; }

.form-label {
    color: var(--clr-text-muted);
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
}

/* ── Input Group ── */
.input-group-text {
    color: var(--clr-text-muted) !important;
    font-size: 0.85rem;
}

/* ── Autocomplete datalist ── */
input[list]::-webkit-calendar-picker-indicator { filter: invert(1); }

/* ══════════════════════════════════════════════════════════════
   BOTÕES BOOTSTRAP OVERRIDE
══════════════════════════════════════════════════════════════ */
.btn {
    border-radius: var(--radius-btn);
    font-weight: 500;
    transition: var(--transition-smooth);
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--clr-primary);
    border-color: var(--clr-primary);
}
.btn-primary:hover {
    background: var(--clr-primary-hover);
    border-color: var(--clr-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31,111,235,.35);
}

.btn-success { background: var(--clr-success); border-color: var(--clr-success); }
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(63,185,80,.35); }

.btn-outline-secondary { border-color: var(--clr-border); color: var(--clr-text-muted); }
.btn-outline-secondary:hover { background: rgba(255,255,255,.05); color: var(--clr-text); }

.btn-outline-light { border-color: rgba(255,255,255,.2); color: rgba(255,255,255,.8); }
.btn-outline-light:hover { background: rgba(255,255,255,.1); }

.btn-outline-warning { border-color: var(--clr-warning); color: var(--clr-warning); }
.btn-outline-warning:hover { background: rgba(210,153,34,.15); }

.btn-outline-danger { border-color: var(--clr-danger); color: var(--clr-danger); }
.btn-outline-danger:hover { background: rgba(248,81,73,.15); }

.btn-outline-primary { border-color: var(--clr-primary); color: var(--clr-primary); }
.btn-outline-primary:hover { background: rgba(31,111,235,.15); }

.btn-outline-info { border-color: var(--clr-info); color: var(--clr-info); }
.btn-outline-info:hover { background: rgba(88,166,255,.15); }

/* ══════════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════════ */
.badge {
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
}

.badge.bg-success { background: rgba(63,185,80,.2) !important; color: var(--clr-success) !important; border: 1px solid rgba(63,185,80,.3); }
.badge.bg-warning { background: rgba(210,153,34,.2) !important; color: var(--clr-warning) !important; border: 1px solid rgba(210,153,34,.3); }
.badge.bg-danger  { background: rgba(248,81,73,.2)  !important; color: var(--clr-danger)  !important; border: 1px solid rgba(248,81,73,.3); }
.badge.bg-primary { background: rgba(31,111,235,.2) !important; color: var(--clr-info)    !important; border: 1px solid rgba(31,111,235,.3); }
.badge.bg-info    { background: rgba(88,166,255,.15) !important; color: var(--clr-info)   !important; border: 1px solid rgba(88,166,255,.25); }
.badge.bg-secondary { background: rgba(255,255,255,.08) !important; color: var(--clr-text-muted) !important; border: 1px solid var(--clr-border); }

.badge.bg-secondary-subtle {
    background: rgba(255,255,255,.05) !important;
    color: var(--clr-text-muted) !important;
    border: 1px solid var(--clr-border) !important;
}

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.toast {
    background: var(--clr-bg-secondary) !important;
    border: 1px solid var(--clr-border) !important;
    color: var(--clr-text) !important;
    border-radius: 10px;
    min-width: 280px;
}
.toast.bg-success { border-color: rgba(63,185,80,.4) !important; background: rgba(63,185,80,.1) !important; }
.toast.bg-danger  { border-color: rgba(248,81,73,.4) !important; background: rgba(248,81,73,.1) !important; }

/* ══════════════════════════════════════════════════════════════
   DROPDOWN DARK
══════════════════════════════════════════════════════════════ */
.dropdown-menu-dark {
    background: var(--clr-bg-secondary) !important;
    border: 1px solid var(--clr-border) !important;
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.dropdown-menu-dark .dropdown-item {
    color: var(--clr-text) !important;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin: 0.1rem 0.4rem;
    transition: var(--transition-smooth);
}
.dropdown-menu-dark .dropdown-item:hover { background: rgba(255,255,255,.07) !important; }
.dropdown-menu-dark .dropdown-item.text-danger { color: var(--clr-danger) !important; }

/* ══════════════════════════════════════════════════════════════
   ALERT
══════════════════════════════════════════════════════════════ */
.alert {
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 0.875rem;
}
.alert-danger {
    background: rgba(248,81,73,.12);
    border-color: rgba(248,81,73,.3);
    color: #f85149;
}

/* ══════════════════════════════════════════════════════════════
   UTILITÁRIOS
══════════════════════════════════════════════════════════════ */
.text-muted { color: var(--clr-text-muted) !important; }
.text-success { color: var(--clr-success) !important; }
.text-danger { color: var(--clr-danger) !important; }
.text-warning { color: var(--clr-warning) !important; }

/* Estilo para exibição de login multilinha */
.login-text {
    white-space: pre-wrap;
    display: inline-block;
    vertical-align: middle;
    text-align: left;
    line-height: 1.4;
}

/* ── Botão copiar login ── */
.btn-copy-login {
    background: none;
    border: none;
    color: var(--clr-text-muted);
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
    margin-left: 0.35rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
    vertical-align: middle;
}

.login-text + .btn-copy-login,
tr:hover .btn-copy-login {
    opacity: .5;
}

.btn-copy-login:hover {
    opacity: 1 !important;
    color: var(--clr-success);
    background: rgba(63,185,80,.12);
}

.btn-copy-login.copied {
    opacity: 1 !important;
    color: var(--clr-success);
}

/* ── Animação de loading em linha da tabela ── */
.row-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}
.row-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
    animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ══════════════════════════════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════════════════════════════ */
@media print {
    body { background: white !important; color: black !important; }
    .navbar-custom, .btn, form { display: none !important; }
    .table-custom { color: black !important; }
    .table-custom thead th { background: #f0f0f0 !important; color: black !important; }
    .table-custom tbody td { border-bottom: 1px solid #ddd !important; }
    .card-panel { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVIDADE
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .stat-card__value { font-size: 1.4rem; }
    .stat-card__icon  { font-size: 1.75rem; }
    .table-custom { font-size: 0.8rem; }
    .btn-action { padding: 0.2rem 0.4rem !important; font-size: 0.72rem !important; }
}
