/* Estilos base y diseño moderno para login y dashboard */

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #0f172a;
}

/* --- LOGIN --- */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #38bdf8 0, #1e3a8a 45%, #020617 100%);
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.auth-card {
    background: rgba(15, 23, 42, 0.9);
    border-radius: 1rem;
    padding: 2rem 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(18px);
}

.auth-header {
    margin-bottom: 1.75rem;
    text-align: center;
    color: #e5e7eb;
}

.app-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-subtitle {
    margin-top: 0.4rem;
    font-size: 0.95rem;
    color: #9ca3af;
}

.auth-form .form-group {
    margin-bottom: 1.1rem;
}

.auth-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: #d1d5db;
}

.auth-form input {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background-color: rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
    font-size: 0.95rem;
}

.auth-form input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.btn-primary {
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.75rem;
    border: none;
    border-radius: 0.7rem;
    background: linear-gradient(to right, #38bdf8, #6366f1);
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.1s ease;
}

.btn-primary:hover {
    opacity: 0.95;
    box-shadow: 0 15px 30px -12px rgba(37, 99, 235, 0.7);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* --- DASHBOARD --- */

.dashboard-body {
    min-height: 100vh;
    background-color: #020617;
    color: #e5e7eb;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(16px);
}

.topbar-left .logo {
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.95rem;
}

.topbar-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-item {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #e5e7eb;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.menu-item:hover {
    background-color: rgba(30, 64, 175, 0.7);
    border-color: rgba(129, 140, 248, 0.8);
}

.menu-item.active {
    background: linear-gradient(to right, #38bdf8, #6366f1);
    border-color: transparent;
}

.topbar-right .user-name {
    font-size: 0.9rem;
    color: #cbd5f5;
    margin-right: 0.75rem;
}

.topbar-right .logout-link {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(248, 113, 113, 0.8);
    color: #fecaca;
    text-decoration: none;
    background-color: rgba(127, 29, 29, 0.6);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.topbar-right .logout-link:hover {
    background-color: rgba(220, 38, 38, 0.85);
    border-color: rgba(248, 113, 113, 1);
    color: #fef2f2;
}

.dashboard-main {
    padding: 1.5rem;
    max-width: 1120px;
    margin: 0 auto;
}

.dashboard-content h2 {
    font-size: 1.4rem;
    margin-bottom: 0.4rem;
}

.dashboard-content p {
    color: #9ca3af;
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.card {
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), rgba(15, 23, 42, 0.98));
    border-radius: 0.9rem;
    padding: 1.1rem 1.2rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
}

.card p {
    font-size: 0.9rem;
    color: #9ca3af;
}

/* --- Usuarios --- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.btn-secondary {
    border: 1px solid rgba(148, 163, 184, 0.7);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    background-color: transparent;
    color: #e5e7eb;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
    background-color: rgba(30, 64, 175, 0.8);
    border-color: rgba(129, 140, 248, 1);
}

.btn-ghost {
    background-color: transparent;
    border-color: rgba(148, 163, 184, 0.6);
    margin-right: 0.5rem;
}

.user-form-card,
.table-card {
    margin-bottom: 1.5rem;
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), rgba(15, 23, 42, 0.98));
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 1.1rem 1.2rem;
}

.user-form-card.is-hidden {
    display: none;
}

.user-form-card.is-visible {
    display: block;
}

.user-form-card h3,
.table-card h3 {
    margin-bottom: 0.75rem;
}

.user-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.9rem;
}

.user-form .form-group {
    display: flex;
    flex-direction: column;
}

.user-form label {
    font-size: 0.85rem;
    color: #cbd5f5;
    margin-bottom: 0.25rem;
}

.user-form input,
.user-form select {
    padding: 0.55rem 0.7rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background-color: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    font-size: 0.9rem;
}

.user-form input:focus,
.user-form select:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.field-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: 0.25rem;
}

.form-actions {
    margin-top: 0.85rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.alert {
    border-radius: 0.75rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.alert ul {
    margin-left: 1rem;
    list-style: disc;
}

.alert-error {
    background-color: rgba(127, 29, 29, 0.8);
    border: 1px solid rgba(248, 113, 113, 0.9);
    color: #fee2e2;
}

.alert-success {
    background-color: rgba(22, 101, 52, 0.85);
    border: 1px solid rgba(74, 222, 128, 0.9);
    color: #dcfce7;
}

.table-wrapper {
    overflow-x: auto;
}

.table-users {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table-users thead {
    background-color: rgba(15, 23, 42, 0.9);
}

.table-users th,
.table-users td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid rgba(30, 64, 175, 0.6);
    text-align: left;
}

.table-users th {
    font-weight: 600;
    color: #cbd5f5;
}

.table-users tr:hover td {
    background-color: rgba(15, 23, 42, 0.8);
}

.empty-state {
    text-align: center;
    color: #9ca3af;
}

.badge-col {
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.badge-type-master {
    background-color: rgba(30, 64, 175, 0.8);
    color: #e0f2fe;
}

.badge-type-administrador {
    background-color: rgba(6, 95, 70, 0.85);
    color: #bbf7d0;
}

.badge-status-active {
    background-color: rgba(22, 163, 74, 0.85);
    color: #bbf7d0;
}

.badge-status-inactive {
    background-color: rgba(127, 29, 29, 0.85);
    color: #fecaca;
}

.actions-col {
    white-space: nowrap;
}

.link-action {
    font-size: 0.8rem;
    color: #60a5fa;
    text-decoration: none;
    margin-right: 0.6rem;
}

.link-action:hover {
    text-decoration: underline;
}

.link-danger {
    color: #fca5a5;
}

@media (max-width: 768px) {
    .dashboard-main {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-secondary {
        width: 100%;
        text-align: center;
    }

    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .btn-primary,
    .btn-secondary,
    .btn-ghost {
        width: 100%;
        text-align: center;
    }

    .table-users th,
    .table-users td {
        padding: 0.45rem 0.4rem;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-menu {
        flex-wrap: wrap;
    }

    .auth-card {
        padding: 1.7rem 1.5rem;
    }
}
