/* =========================================================
   SISTEMA DE GESTIÓN DE SEGURIDAD - CSS RESPONSIVE
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ---- Variables ---- */
:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --primary-light: rgba(67, 97, 238, 0.12);
    --success: #2ec4b6;
    --danger: #ef233c;
    --warning: #ff9f1c;
    --secondary: #6c757d;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #2b2d42;
    --text-muted: #6c757d;
    --border: #eef0f3;
    --sidebar-bg: #1e2139;
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 50px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.09);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.12);
    --transition: all 0.28s ease;
    --topbar-h: 64px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

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

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

/* =========================================================
   LAYOUT
   ========================================================= */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Overlay (móvil) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

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

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-brand span {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

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

.sidebar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.35);
    padding: 12px 10px 6px;
    font-weight: 600;
}

.sidebar ul {
    list-style: none;
}

.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: rgba(255, 255, 255, 0.65);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.sidebar ul li a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar ul li a:hover,
.sidebar ul li a.active {
    background: var(--primary-light);
    color: #fff;
    transform: translateX(4px);
    text-decoration: none;
}

.sidebar ul li a.active {
    color: #7c9eff;
}

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

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
}

.sidebar-footer a:hover {
    background: rgba(239, 35, 60, 0.15);
    color: #ef233c;
    text-decoration: none;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1.3rem;
    transition: var(--transition);
}

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

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.88rem;
    font-weight: 500;
}

.user-badge .avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ---- Page Content ---- */
.page-content {
    padding: 28px;
    flex: 1;
}

/* =========================================================
   COMPONENTS
   ========================================================= */

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

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

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: rgba(67, 97, 238, 0.12);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(46, 196, 182, 0.12);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(255, 159, 28, 0.12);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(239, 35, 60, 0.12);
    color: var(--danger);
}

.stat-info h3 {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 22px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-pill);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

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

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

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

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

.btn-success:hover {
    background: #25a99d;
}

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

.btn-danger:hover {
    background: #c8001e;
}

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

.btn-secondary:hover {
    background: #545b62;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

.btn-block {
    width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 500;
    font-size: 0.88rem;
    color: #444;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    font-family: inherit;
    transition: var(--transition);
    background: #fff;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.14);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* Alerts */
.alert {
    padding: 13px 18px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.92rem;
    border-left: 4px solid transparent;
}

.alert-danger {
    background: #fff0f2;
    color: #c8001e;
    border-left-color: var(--danger);
}

.alert-success {
    background: #e8faf8;
    color: #1a8a7e;
    border-left-color: var(--success);
}

.alert-warning {
    background: #fff8ec;
    color: #b36b00;
    border-left-color: var(--warning);
}

.alert-info {
    background: #eef2ff;
    color: #3a0ca3;
    border-left-color: var(--primary);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
    padding: 13px 16px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.92rem;
}

table tr:last-child td {
    border-bottom: none;
}

table tbody tr:hover td {
    background: #f8f9ff;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(46, 196, 182, 0.15);
    color: #1a8a7e;
}

.badge-danger {
    background: rgba(239, 35, 60, 0.12);
    color: #c8001e;
}

.badge-warning {
    background: rgba(255, 159, 28, 0.15);
    color: #b36b00;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-secondary {
    background: rgba(108, 117, 125, 0.12);
    color: #495057;
}

/* Wizard Steps */
.step-indicator {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 36px;
    position: relative;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    gap: 4px;
}

.step-indicator::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    flex: 1;
    min-width: 60px;
    text-align: center;
}

.step::before {
    content: counter(step);
    counter-increment: step;
    width: 34px;
    height: 34px;
    line-height: 34px;
    display: block;
    text-align: center;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: var(--card);
    border: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.step.active {
    color: var(--primary);
}

.step.active::before {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(67, 97, 238, 0.18);
}

.step.completed {
    color: var(--success);
}

.step.completed::before {
    content: '✓';
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2139 0%, #2d3561 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

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

.login-logo .icon-wrap {
    width: 72px;
    height: 72px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 2rem;
    color: var(--primary);
}

.login-logo h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

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

/* Password toggle */
.input-group {
    position: relative;
}

.input-group .form-control {
    padding-right: 44px;
}

.input-group .toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    transition: var(--transition);
}

.input-group .toggle-pass:hover {
    color: var(--primary);
}

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone i {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Utility */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 12px;
}

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

/* =========================================================
   RESPONSIVE – MEDIA QUERIES
   ========================================================= */

/* Tablet */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 768px) {

    /* Sidebar se oculta fuera de pantalla */
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    /* Main content ocupa todo el ancho */
    .main-content {
        margin-left: 0;
    }

    /* Mostrar botón hamburguesa */
    .hamburger {
        display: flex;
    }

    /* Topbar */
    .topbar {
        padding: 0 16px;
    }

    .topbar-title {
        font-size: 0.9rem;
    }

    /* Page content */
    .page-content {
        padding: 16px;
    }

    /* Cards */
    .card {
        padding: 18px;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        gap: 12px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .stat-info h3 {
        font-size: 1.4rem;
    }

    /* Form rows */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Wizard steps: ocultar texto en móvil muy pequeño */
    .step {
        font-size: 0;
    }

    .step::before {
        margin-bottom: 0;
    }

    /* Botones en móvil */
    .btn {
        padding: 9px 16px;
        font-size: 0.85rem;
    }

    /* Tablas: scroll horizontal */
    .table-responsive {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }

    /* User badge simplificado */
    .user-badge span {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-container {
        padding: 28px 20px;
    }

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