/* =========================================================
   Admin Lechitax - Estilos
   Panel de administración independiente
   ========================================================= */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --sidebar-width: 220px;
    --header-height: 60px;
    --radius: 8px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* ── Header ───────────────────────────────────────────────── */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-brand {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.header-brand strong {
    color: var(--accent);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-user-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.layout {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
}

.sidebar-link {
    display: block;
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.92rem;
    transition: all 0.2s;
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent);
    font-weight: 500;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section.hidden {
    display: none;
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 0.65rem 0.9rem;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    resize: vertical;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: var(--error);
    color: #fff;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

.hidden {
    display: none !important;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    background: var(--bg-input);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #818cf8);
    border-radius: 100px;
    width: 0%;
    transition: width 0.4s ease;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.92rem;
    border: 1px solid transparent;
}

.alert-success,
.alert.success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.alert-error,
.alert.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

/* ── Video List ───────────────────────────────────────────── */
.video-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.video-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: border-color 0.2s;
}

.video-item:hover {
    border-color: var(--accent);
}

.video-item-info {
    flex: 1;
    min-width: 0;
}

.video-item-title {
    font-weight: 500;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.video-item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.video-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-action {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.btn-action:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-action.btn-delete:hover {
    border-color: var(--error);
    color: var(--error);
}

.empty-msg {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem 0;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-dots {
    color: var(--text-secondary);
    padding: 0 0.25rem;
}

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

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

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.2rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    z-index: 300;
    max-width: 360px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ── Login Page ───────────────────────────────────────────── */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.login-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── WebSocket indicator ──────────────────────────────────── */
.ws-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.ws-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--error);
    transition: background 0.3s;
}

.ws-dot.connected {
    background: var(--success);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
    }

    .layout {
        flex-direction: column;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0.5rem;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
/* ─── Tag Input Component ─────────────────────────────────────────────────── */
.tag-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.35rem 0.625rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: text;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}
.tag-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.45rem 0.18rem 0.55rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 220px;
    animation: chip-in 0.15s ease;
}
@keyframes chip-in {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.tag-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.tag-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border: none;
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    line-height: 1;
}
.tag-chip-remove:hover { background: #ef4444; color: #fff; }
.tag-input-text {
    flex: 1;
    min-width: 8rem;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 0.1rem 0;
}
.tag-input-text::placeholder { color: var(--text-secondary); }
.tag-autocomplete {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    z-index: 200;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.tag-autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(51,65,85,0.5);
    transition: background 0.1s;
}
.tag-autocomplete-item:last-child { border-bottom: none; }
.tag-autocomplete-item:hover,
.tag-autocomplete-item.ti-active { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.tag-hint {
    font-size: 0.73rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}
.tag-hint kbd {
    display: inline-block;
    padding: 0.08rem 0.3rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.68rem;
    font-family: monospace;
    color: var(--text-primary);
}
