/* ==============================================
   PANEL CMS — Clínica Ángeles de la Salud
   ============================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #cc0b2f;
    --primary-dark: #9b0824;
    --primary-light: #fff0f3;
    --text: #1e293b;
    --text-soft: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --white: #ffffff;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);
    --radius: 14px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── LOGIN PAGE ─────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #7f1d1d 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: 24px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-logo p {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-top: 4px;
}

.login-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    margin-top: 10px;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 7px;
}

.form-group label i {
    color: var(--primary);
    margin-right: 5px;
    font-size: 0.8rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(204,11,47,0.12);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(204,11,47,0.3);
    margin-top: 8px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(204,11,47,0.4);
}

.btn-login:active { transform: translateY(0); }

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 14px;
    display: none;
    align-items: center;
    gap: 8px;
}

.login-error.visible { display: flex; }

/* ── DASHBOARD LAYOUT ───────────────────────── */
.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    background: #0f172a;
    color: #e2e8f0;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 24px 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.sidebar-brand-text h2 {
    font-size: 0.92rem;
    font-weight: 800;
    color: #f1f5f9;
    line-height: 1.2;
}

.sidebar-brand-text span {
    font-size: 0.72rem;
    color: #64748b;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #475569;
    padding: 0 10px;
    margin: 16px 0 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 2px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-link:hover, .sidebar-link.active {
    background: rgba(204,11,47,0.18);
    color: #fca5a5;
}

.sidebar-link i { width: 18px; text-align: center; font-size: 0.9rem; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: #475569;
}

.btn-logout {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    font-size: 0.9rem;
}

.btn-logout:hover { color: #fca5a5; background: rgba(204,11,47,0.15); }

/* Main content */
.admin-main {
    padding: 32px 36px;
    overflow-y: auto;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

.admin-page-title span {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-soft);
    display: block;
    margin-top: 2px;
}

/* ── STATS CARDS ────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.red   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.gray  { background: #f1f5f9; color: #475569; }

.stat-info strong {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-info span {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-top: 4px;
    display: block;
}

/* ── SECCIÓN DE AGREGAR VIDEO ───────────────── */
.admin-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.admin-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-card-title i { color: var(--primary); }

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

/* Form add video */
.add-video-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: flex-end;
}

.add-video-form .form-group { margin-bottom: 0; }

.url-input-wrap {
    position: relative;
}

.url-input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
}

.url-input-wrap .form-control {
    padding-left: 38px;
}

.btn-add {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 12px rgba(204,11,47,0.28);
}

.btn-add:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(204,11,47,0.36); }
.btn-add:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Preview de video detectado */
.video-preview-bar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.video-preview-bar.visible { display: flex; }

.video-preview-bar img {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.video-preview-info { flex: 1; }
.video-preview-info strong { font-size: 0.85rem; color: var(--success); font-weight: 700; }
.video-preview-info small { display: block; font-size: 0.78rem; color: #64748b; }

/* Campos extra del video */
.add-video-extras {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.add-video-extras.visible { display: grid; }

/* ── LISTA DE VIDEOS ────────────────────────── */
.video-list { display: flex; flex-direction: column; gap: 0; }

.video-item {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.video-item:last-child { border-bottom: none; }
.video-item:hover { background: #fafafa; }
.video-item.inactive { opacity: 0.55; }

.video-item-thumb {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
}

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

.video-item-info {}
.video-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.3;
}

.video-item-meta {
    font-size: 0.75rem;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.video-item-meta .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
}

.badge.active   { background: #dcfce7; color: var(--success); }
.badge.inactive { background: #fef2f2; color: var(--danger); }
.badge.featured { background: #fef9c3; color: var(--warning); }

.video-item-id {
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Acciones */
.video-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-action {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.2s;
    font-family: inherit;
}

.btn-action:hover { transform: scale(1.1); }

.btn-toggle  { background: #f0fdf4; color: var(--success); }
.btn-toggle.off { background: #fef2f2; color: var(--danger); }
.btn-edit    { background: #eff6ff; color: #2563eb; }
.btn-delete  { background: #fef2f2; color: var(--danger); }

/* Toggle switch */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle {
    position: relative;
    width: 42px;
    height: 24px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 12px;
    transition: background 0.25s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── MODAL EDITAR VIDEO ─────────────────────── */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,12,20,0.75);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.admin-modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.admin-modal-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
}

.admin-modal-overlay.visible .admin-modal-box { transform: scale(1); }

.admin-modal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

.btn-cancel {
    padding: 10px 20px;
    background: var(--bg);
    color: var(--text-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-cancel:hover { background: var(--border); }

.btn-save {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: background 0.2s;
}

.btn-save:hover { background: var(--primary-dark); }

/* ── TOAST NOTIFICATIONS ────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 12px;
    background: #1e293b;
    color: white;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
    min-width: 260px;
}

.toast.success i { color: #4ade80; }
.toast.error   i { color: #f87171; }
.toast.info    i { color: #60a5fa; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── ESTADO VACÍO ───────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-soft);
}

.empty-state i {
    font-size: 3rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ── LOADING SPINNER ────────────────────────── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; height: auto; }
    .admin-main { padding: 20px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .add-video-form { grid-template-columns: 1fr; }
    .add-video-extras { grid-template-columns: 1fr; }
    .video-item { grid-template-columns: 70px 1fr; }
    .video-item-actions { grid-column: 1/-1; justify-content: flex-end; }
}

@media (max-width: 500px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
}
