/* ============================================
   SIGA - Estilos Unificados
   Sistema Integral de Gestión de Afiliados
   ============================================ */

/* === Variables de color === */
:root {
    --siga-primary: #1a1a2e;
    --siga-secondary: #16213e;
    --siga-accent: #0f3460;
    --siga-blue: #4361ee;
    --siga-purple: #7209b7;
    --siga-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --siga-gradient-light: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --siga-success: #28a745;
    --siga-warning: #ffc107;
    --siga-danger: #dc3545;
    --siga-info: #17a2b8;
    --siga-gray-100: #f8f9fa;
    --siga-gray-200: #e9ecef;
    --siga-gray-600: #6c757d;
    --siga-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --siga-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --siga-radius: 10px;
    --siga-radius-lg: 16px;
}

/* === Base === */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
}

/* === Navbar Admin === */
.navbar-siga {
    background: var(--siga-gradient) !important;
    padding: 0.6rem 0;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
}

.navbar-siga .navbar-brand {
    color: white !important;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-siga .navbar-brand img {
    /* logo-white.png already white, no filter needed */
}

.navbar-siga .nav-link {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.9rem !important;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.navbar-siga .nav-link:hover,
.navbar-siga .nav-link.active {
    color: white !important;
    background: rgba(255, 255, 255, 0.12);
}

.navbar-siga .nav-link svg {
    margin-right: 4px;
    opacity: 0.8;
}

.navbar-siga .navbar-user {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar-siga .navbar-user svg {
    opacity: 0.6;
}

.navbar-siga .btn-logout {
    color: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.82rem;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.navbar-siga .btn-logout:hover {
    color: white !important;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

/* === Navbar Portal === */
.navbar-portal {
    background: var(--siga-gradient-light) !important;
    padding: 0.6rem 0;
    box-shadow: 0 2px 15px rgba(102, 126, 234, 0.3);
}

.navbar-portal .navbar-brand {
    color: white !important;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-portal .navbar-brand img {
    /* logo-white.png already white, no filter needed */
}

.navbar-portal .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.9rem !important;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.navbar-portal .nav-link:hover,
.navbar-portal .nav-link.active {
    color: white !important;
    background: rgba(255, 255, 255, 0.15);
}

/* === Footer === */
.siga-footer {
    background: var(--siga-primary);
    color: rgba(255, 255, 255, 0.5);
    padding: 1rem 0;
    margin-top: 2rem;
    font-size: 0.82rem;
    text-align: center;
}

.siga-footer a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

.siga-footer a:hover {
    color: white;
}

/* === Cards === */
.siga-card {
    background: white;
    border: none;
    border-radius: var(--siga-radius);
    box-shadow: var(--siga-shadow);
    transition: box-shadow 0.2s ease;
}

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

.siga-card .card-header {
    background: var(--siga-gray-100);
    border-bottom: 1px solid var(--siga-gray-200);
    font-weight: 600;
    border-radius: var(--siga-radius) var(--siga-radius) 0 0 !important;
    padding: 0.85rem 1.2rem;
}

/* === Stat Cards === */
.stat-card {
    background: white;
    border: none;
    border-radius: var(--siga-radius);
    box-shadow: var(--siga-shadow);
    padding: 1.3rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--siga-shadow-lg);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-card .stat-icon.bg-primary { background: rgba(67, 97, 238, 0.12); color: var(--siga-blue); }
.stat-card .stat-icon.bg-success { background: rgba(40, 167, 69, 0.12); color: var(--siga-success); }
.stat-card .stat-icon.bg-warning { background: rgba(255, 193, 7, 0.12); color: #e6a800; }
.stat-card .stat-icon.bg-info    { background: rgba(23, 162, 184, 0.12); color: var(--siga-info); }
.stat-card .stat-icon.bg-purple  { background: rgba(114, 9, 183, 0.12); color: var(--siga-purple); }

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #2d3436;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--siga-gray-600);
    margin-top: 2px;
}

/* === Page Header === */
.page-header {
    padding: 1.2rem 0 0.8rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--siga-gray-200);
}

.page-header h4 {
    font-weight: 700;
    color: var(--siga-primary);
    margin: 0;
}

/* === Tables === */
.table {
    font-size: 0.88rem;
}

.table thead th {
    background: var(--siga-gray-100);
    color: var(--siga-primary);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--siga-gray-200);
    padding: 0.7rem;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.6rem 0.7rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.04);
}

/* === Buttons === */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.88rem;
    padding: 0.45rem 1rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--siga-blue);
    border-color: var(--siga-blue);
}

.btn-primary:hover {
    background: #3651d4;
    border-color: #3651d4;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
}

/* === Status Badges === */
.badge-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-badge-activo,
.badge-activo {
    background-color: var(--siga-success);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge-inactivo,
.badge-inactivo {
    background-color: var(--siga-danger);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* === Forms === */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--siga-blue);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.88rem;
    color: #4a4a4a;
    margin-bottom: 0.3rem;
}

/* === Alerts === */
.alert {
    border-radius: var(--siga-radius);
    border: none;
    font-size: 0.9rem;
}

/* === Credencial Card === */
.credencial-card {
    background: var(--siga-gradient);
    color: white;
    border-radius: 15px;
    padding: 25px;
    max-width: 500px;
    position: relative;
    overflow: hidden;
}

.credencial-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.credencial-foto {
    width: 100px;
    height: 120px;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

.credencial-qr {
    background: white;
    padding: 10px;
    border-radius: 8px;
    display: inline-block;
}

/* === DataTables Override === */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px !important;
    border: 1px solid #d1d5db !important;
    padding: 0.4rem 0.8rem !important;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 8px !important;
    border: 1px solid #d1d5db !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--siga-blue) !important;
    border-color: var(--siga-blue) !important;
    color: white !important;
    border-radius: 6px;
}

/* === Select2 Override === */
.select2-container--default .select2-selection--single {
    border-radius: 8px !important;
    border: 1px solid #d1d5db !important;
    height: 38px !important;
    padding-top: 4px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar-siga .nav-link,
    .navbar-portal .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem !important;
    }

    .stat-card {
        margin-bottom: 0.5rem;
    }
}

/* === Animations === */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

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

.login-side-image {
    background: url('background.jpg') center/cover no-repeat;
    position: relative;
}

.login-side-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(26,26,46,0.7) 0%, rgba(15,52,96,0.5) 100%);
}

.login-side-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 2rem;
    color: white;
    text-align: center;
}

.login-side-content h2 {
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-side-content p {
    font-size: 1rem;
    opacity: 0.85;
}

.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #f0f2f5;
}

.login-card {
    background: white;
    border-radius: var(--siga-radius-lg);
    box-shadow: var(--siga-shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
}

.login-card .login-logo {
    width: 80px;
    margin-bottom: 1rem;
}

.login-card .login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--siga-primary);
    margin-bottom: 0.3rem;
}

.login-card .login-subtitle {
    font-size: 0.85rem;
    color: var(--siga-gray-600);
    margin-bottom: 1.5rem;
}

.login-badge {
    display: inline-block;
    background: var(--siga-gradient-light);
    color: white;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.login-badge-admin {
    background: var(--siga-gradient);
}

.login-card .btn-login {
    background: var(--siga-blue);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.95rem;
    width: 100%;
    transition: all 0.2s ease;
}

.login-card .btn-login:hover {
    background: #3651d4;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.4);
    transform: translateY(-1px);
}

.login-card .btn-login-portal {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.login-card .btn-login-portal:hover {
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
    transform: translateY(-1px);
}

.login-card .input-group .btn {
    border-color: #d1d5db;
    color: var(--siga-gray-600);
}

.login-card .form-text {
    font-size: 0.78rem;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 1.2rem 0;
    color: var(--siga-gray-600);
    font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--siga-gray-200);
}

.login-divider span {
    padding: 0 0.8rem;
}

@media (max-width: 768px) {
    .login-side-image {
        display: none;
    }
    .login-card {
        padding: 2rem 1.5rem;
    }
}

/* ============================================
   PORTAL MOBILE OPTIMIZATION
   ============================================ */

/* --- General mobile --- */
@media (max-width: 576px) {
    main.container {
        padding-left: 12px;
        padding-right: 12px;
        margin-top: 1rem !important;
    }

    h4 {
        font-size: 1.2rem;
    }

    .page-header {
        padding: 0.8rem 0 0.6rem;
    }

    .page-header h4 {
        font-size: 1.15rem;
    }

    /* Navbar mobile */
    .navbar-portal .navbar-brand,
    .navbar-siga .navbar-brand {
        font-size: 1.1rem;
    }

    .navbar-portal .nav-link,
    .navbar-siga .nav-link {
        padding: 0.6rem 0.8rem !important;
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .navbar-portal .nav-link svg,
    .navbar-siga .nav-link svg {
        margin-right: 8px;
    }

    /* Cards general */
    .card, .siga-card {
        border-radius: 10px;
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 0.8rem;
    }

    .card-header {
        padding: 0.7rem 0.8rem;
        font-size: 0.88rem;
    }

    /* Tables responsive */
    .table {
        font-size: 0.8rem;
    }

    .table thead th {
        font-size: 0.72rem;
        padding: 0.5rem;
        white-space: nowrap;
    }

    .table tbody td {
        padding: 0.4rem 0.5rem;
    }

    /* Buttons mobile */
    .btn {
        font-size: 0.82rem;
        padding: 0.4rem 0.8rem;
    }

    .btn-lg {
        font-size: 0.9rem !important;
        padding: 0.5rem 1rem !important;
    }

    /* Badge */
    .badge {
        font-size: 0.68rem;
    }

    /* Footer */
    .siga-footer {
        font-size: 0.75rem;
        padding: 0.8rem 0;
    }
}

/* --- Portal Dashboard (index.php) mobile --- */
@media (max-width: 576px) {
    /* Welcome section */
    .row.mb-4 > .col-md-8 .p-4 {
        padding: 1rem !important;
    }

    .row.mb-4 > .col-md-8 .p-4 img {
        width: 50px !important;
        height: 50px !important;
    }

    .row.mb-4 > .col-md-8 .p-4 h4 {
        font-size: 1rem;
    }

    .row.mb-4 > .col-md-8 .p-4 p {
        font-size: 0.8rem;
    }

    /* "Ver Mi Credencial" button */
    .row.mb-4 > .col-md-4 {
        text-align: center !important;
        justify-content: center !important;
        margin-top: 0.5rem;
    }

    /* Stat cards */
    .row.mb-4 > .col-md-4 .card {
        margin-bottom: 0.5rem !important;
    }

    .row.mb-4 > .col-md-4 .card .card-body {
        padding: 0.8rem;
    }

    .row.mb-4 > .col-md-4 .card .card-body h5 {
        font-size: 1.3rem;
    }

    .row.mb-4 > .col-md-4 .card .card-body p {
        font-size: 0.8rem;
        margin-bottom: 0;
    }

    /* Mis Datos table */
    .table-sm.table-borderless td {
        font-size: 0.8rem;
        padding: 3px 4px !important;
    }
}

/* --- Credencial mobile --- */
@media (max-width: 576px) {
    .credencial-card {
        padding: 18px;
        max-width: 100%;
        border-radius: 12px;
    }

    .credencial-card h5 {
        font-size: 0.95rem;
    }

    .credencial-card table {
        font-size: 0.75rem !important;
    }

    .credencial-foto {
        width: 75px;
        height: 95px;
    }

    .credencial-qr canvas,
    .credencial-qr img {
        width: 100px !important;
        height: 100px !important;
    }

    /* Options card next to credencial */
    .col-md-5 .card {
        margin-top: 1rem;
    }

    .col-md-5 .card .card-body p,
    .col-md-5 .card .card-body small {
        font-size: 0.82rem;
    }
}

/* --- Documentos mobile --- */
@media (max-width: 576px) {
    .doc-item {
        padding: 8px 10px;
    }

    .doc-icon {
        width: 34px;
        height: 34px;
        margin-right: 10px;
    }

    .doc-icon svg {
        width: 16px;
        height: 16px;
    }

    .doc-name {
        font-size: 0.78rem;
        line-height: 1.2;
    }

    .doc-type {
        font-size: 0.65rem;
    }

    /* Stack docs single column on mobile */
    .doc-item .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Comunicado items */
    .comunicado-item {
        flex-direction: column;
        gap: 0.3rem;
    }

    .comunicado-item .btn {
        align-self: flex-start;
        margin-top: 0.3rem;
        margin-left: 0 !important;
    }
}

/* --- Popup/Modal mobile --- */
@media (max-width: 576px) {
    #modalInvitacion .modal-dialog {
        max-width: 92vw !important;
        margin: 1rem auto;
    }

    #modalInvitacion .modal-content {
        border-radius: 12px !important;
    }

    #modalInvitacion .btn-close {
        top: 6px !important;
        right: 6px !important;
        padding: 6px !important;
    }
}

/* --- Stat card mobile --- */
@media (max-width: 576px) {
    .stat-card {
        padding: 0.9rem;
        gap: 0.7rem;
    }

    .stat-card .stat-icon {
        width: 42px;
        height: 42px;
        border-radius: 10px;
    }

    .stat-card .stat-icon svg {
        width: 20px;
        height: 20px;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .stat-card .stat-label {
        font-size: 0.72rem;
    }
}

/* --- Force single column on mobile --- */
@media (max-width: 768px) {
    .row > .col-md-6,
    .row > .col-md-4,
    .row > .col-md-8,
    .row > .col-md-5,
    .row > .col-md-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
