/* InstaView Premium Design System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Premium Dark Theme Palette */
    --bg-dark: #0f172a;
    /* Slate 900 */
    --bg-card: #1e293b;
    /* Slate 800 */
    --bg-input: #334155;
    /* Slate 700 */

    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --primary-glow: rgba(99, 102, 241, 0.5);

    --accent: #ec4899;
    /* Pink 500 */
    --success: #10b981;
    /* Emerald 500 */
    --danger: #ef4444;
    /* Red 500 */

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);

    --radius: 16px;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-input);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.2s;
}

p {
    margin-bottom: 1rem;
}

/* Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    z-index: 10;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Nav Links */
.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), transparent);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.nav-link i {
    font-size: 1.4rem;
}

/* Main Content */
.main-content {
    flex: 1;
    background: radial-gradient(circle at top right, #1e1e2e, var(--bg-dark));
    padding: 2.5rem;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

#pageTitle {
    font-size: 2rem;
}

/* Cards & Glassmorphism */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease, border-color 0.3s;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Inputs */
input,
select,
textarea {
    width: 100%;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: 0.3s;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
    background: #475569;
}

/* Checkbox specific styling for form */
input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
    /* Red-700 */
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
    padding: 0.85rem 1.75rem;
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.3s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-main);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    padding: 1rem 0.5rem;
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 -2px 10px var(--primary-glow);
}

/* Member Grid */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.member-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    text-align: center;
    border-radius: var(--radius);
    transition: 0.3s;
}

.member-card:hover {
    border-color: var(--primary);
}

.avatar-placeholder {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--bg-input), var(--bg-card));
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    border: 2px solid var(--glass-border);
}

/* Auth Page */
.auth-body {
    background: radial-gradient(circle at center, #1e293b, #0f172a);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Animated Background Orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 350px;
    height: 350px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    bottom: -10%;
    right: -10%;
    animation-delay: 7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #3b82f6, var(--primary));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.login-container {
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(30px);
    padding: 3rem;
    width: 450px;
    max-width: 90%;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    text-align: center;
    position: relative;
    z-index: 10;
}

.login-header {
    margin-bottom: 2.5rem;
}

.logo-icon {
    width: 160px;
    height: 160px;
    margin: 0 auto 1.5rem;
    background: transparent;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon i {
    font-size: 2.5rem;
    color: white;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.5rem;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    }

    50% {
        box-shadow: 0 10px 40px rgba(99, 102, 241, 0.6);
    }
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
}

.input-group {
    position: relative;
    margin-bottom: 1.25rem;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.25rem;
    z-index: 1;
    pointer-events: none;
}

.input-group input {
    padding-left: 3rem;
    text-align: left;
}

.btn-login {
    width: 100%;
    padding: 1rem 1.75rem;
    font-size: 1.05rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-login i {
    transition: transform 0.3s;
}

.btn-login:hover i {
    transform: translateX(4px);
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.login-footer strong {
    color: var(--primary);
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    display: none;
}

.error-msg:not(:empty) {
    display: block;
}

/* Notifications */
#notificationsArea .card {
    background: rgba(234, 88, 12, 0.1);
    /* Orange tint */
    border-color: rgba(234, 88, 12, 0.3);
}

#notificationsArea li {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(234, 88, 12, 0.1);
    color: #fdba74;
    /* Orange 300 */
}

#notificationsArea li:last-child {
    border-bottom: none;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Table Styling */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

td {
    padding: 1rem;
    background: rgba(30, 41, 59, 0.4);
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

tr td:first-child {
    border-left: 1px solid var(--glass-border);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

tr td:last-child {
    border-right: 1px solid var(--glass-border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

tr:hover td {
    background: rgba(45, 55, 72, 0.6);
}

/* User Form */
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Admin Mode Toggle Switch */
.admin-toggle-container {
    margin-top: 2rem;
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
}

.admin-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.admin-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.admin-toggle-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.admin-toggle-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--bg-input);
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.3s;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.toggle-switch.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
    transform: translateX(24px);
}

.toggle-switch:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

/* --- RESPONSIVE DESIGN ADDITIONS --- */

/* 1. Ajustes para Tablets y Pantallas Medianas (Laptops pequeñas) */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        padding: 1.5rem;
    }

    #pageTitle {
        font-size: 1.75rem;
    }

    .main-content {
        padding: 1.5rem;
    }
}

/* 2. Ajustes para Tablets y Móviles Grandes (Layout colapsado) */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
        /* El sidebar ahora iría arriba o se oculta */
        height: auto;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 1rem 1.5rem;
    }

    .logo {
        margin-bottom: 1rem;
        justify-content: center;
    }

    /* Navegación horizontal en móviles para ahorrar espacio */
    .sidebar nav {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .nav-link {
        margin-bottom: 0;
        white-space: nowrap;
        padding: 0.75rem 1rem;
    }

    .nav-link:hover {
        transform: none;
    }

    .admin-toggle-container {
        display: none;
        /* Opcional: ocultar switch de admin en el nav móvil */
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    /* Tablas responsivas: las convertimos en "cards" */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 1rem;
        background: var(--bg-card);
        border-radius: var(--radius);
        border: 1px solid var(--glass-border);
    }

    td {
        border: none !important;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }

    td:before {
        content: attr(data-label);
        /* Necesitarás añadir data-label en tu HTML */
        position: absolute;
        left: 1rem;
        width: 45%;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
    }

    /* Grid de miembros */
    .members-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
}

/* 3. Ajustes para Móviles Pequeños (iPhone SE, etc) */
@media (max-width: 480px) {
    .login-container {
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }

    .logo-icon {
        width: 100px;
        height: 100px;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .tabs {
        gap: 0.75rem;
        overflow-x: auto;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        /* Botones de ancho completo en móvil */
        margin-bottom: 0.5rem;
    }
}

/* 4. Fix para los Orbes de fondo en móviles (mejorar rendimiento) */
@media (max-width: 768px) {
    .orb {
        filter: blur(50px);
        opacity: 0.4;
    }

    .orb-1 {
        width: 200px;
        height: 200px;
    }

    .orb-2 {
        width: 180px;
        height: 180px;
    }

    .orb-3 {
        display: none;
    }

    /* Quitamos uno para que no sature la pantalla */
}