@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --primary-blue: #0056b3;
    --primary-blue-hover: #004494;
    --accent-red: #e11d48;
    --accent-green: #22c55e;
    --accent-orange: #f97316;
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

html {
    overflow-y: scroll;
    /* Force vertical scrollbar to prevent layout shift */
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-white);
}

/* --- Login Styles --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
    /* Dark Blue Gradient */
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* Login Card: Deep Dark Background (Glass style) */
/* Login Card: Glowing Blue Glass Effect */
.login-card {
    background: rgba(15, 23, 42, 0.6);
    /* Semi-transparent dark blue */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Glowing Border */
    border: 1px solid rgba(56, 189, 248, 0.5);
    /* Cyan/Light Blue border */

    /* Outer and Inner Glow */
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4),
        0 0 60px rgba(56, 189, 248, 0.2),
        inset 0 0 20px rgba(56, 189, 248, 0.1);

    color: #ffffff;
    padding: 3rem;
    border-radius: 30px;
    /* More rounded */
    width: 380px;
    max-width: 95%;
    z-index: 1;
    text-align: center;
    border: none;
}

/* Logo Container: White Circle */
.logo-circle {
    width: 140px;
    height: 140px;
    background: #ffffff;
    border-radius: 50%;
    margin: 0 auto 2rem auto;
    /* Center horizontally */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.login-logo-img {
    width: 90px;
    /* Increased size */
    height: auto;
    margin-bottom: 5px;
}

.brand-text {
    color: #0056b3;
    /* Primary Blue */
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Override labels inside login card */
/* Override labels inside login card */
.login-card .form-group label {
    color: #e2e8f0;
    /* Light gray */
}

/* --- Universal Form Controls (Inputs, Selects, Textareas) --- */
.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-white);
    font-size: 1rem;
    transition: all 0.3s ease;
}

/* Specific Fix for Selects */
select.form-control {
    background-color: #1e293b;
    /* Solid dark background to prevent transparency issues */
    color: #f8fafc;
    border: 1px solid #475569;
    cursor: pointer;
    appearance: none;
    /* Remove default arrow in some browsers for custom styling if needed, keeping simple for now */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
    /* Space for arrow */
}

/* Fix for Options dropdown */
select.form-control option {
    background-color: #1e293b;
    color: #f8fafc;
    padding: 10px;
}

/* Fix for Date Inputs */
input[type="date"].form-control {
    background-color: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    color-scheme: dark;
    /* Ensures calendar popup is dark */
}

/* Focus States */
.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.15);
}

/* Specific styling for inputs inside the white login card */
/* Specific styling for inputs inside the dark login card */
/* Specific styling for inputs inside the dark login card */
.login-card .form-control {
    background: #ffffff;
    /* Fondo blanco */
    border: 1px solid #e2e8f0;
    color: #1e293b;
    /* Texto oscuro */
    font-weight: 500;
}

.login-card .form-control:focus {
    background: #ffffff;
    color: #0f172a;
}

.form-control:disabled,
.form-control[readonly] {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    cursor: not-allowed;
    border-color: transparent;
}

.btn-primary {
    padding: 14px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 86, 179, 0.3);
}

/* Login-specific: full-width button */
.login-card .btn-primary {
    width: 100%;
    margin-top: 1rem;
}


/* --- Dashboard Layout (Preserved) --- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 999;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
    /* Habilitar scroll */
}

/* Scrollbar Personalizado para Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.sidebar-header {
    margin-bottom: 3rem;
    text-align: center;
}

/* NEW: Logo Container for Sidebar */
.logo-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: inline-block;
    /* Wraps content */
    width: 100%;
    text-align: center;
}

.sidebar-logo {
    width: 100%;
    max-width: 180px;
    /* Adjusted max-width */
    height: auto;
    object-fit: contain;
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(0, 86, 179, 0.1);
    color: var(--primary-blue);
}

.nav-icon {
    margin-right: 12px;
    font-size: 1.2rem;
}

.btn-logout {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    color: var(--accent-red);
    border: 1px solid rgba(225, 29, 72, 0.2);
    border-radius: 12px;
    text-decoration: none;
    background: rgba(225, 29, 72, 0.05);
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-logout:hover {
    background: var(--accent-red);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    transition: margin-left 0.3s ease-in-out;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 100;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.metric-card {
    background: var(--glass-bg);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-card .metric-content {
    flex: 1;
}

.metric-card.blue {
    border-bottom: 4px solid var(--primary-blue);
}

.metric-card.green {
    border-bottom: 4px solid var(--accent-green);
}

.metric-card.orange {
    border-bottom: 4px solid #ffffff;
}

.metric-card.red {
    border-bottom: 4px solid var(--accent-red);
}

.metric-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-white);
}

/* Iconos pequeños en las tarjetas principales */
.metrics-grid .metric-card .metric-icon-small {
    font-size: 1.5rem;
    opacity: 0.3;
    margin-left: 1rem;
}

.metrics-grid .metric-card.blue .metric-icon-small {
    color: var(--primary-blue);
}

.metrics-grid .metric-card.green .metric-icon-small {
    color: var(--accent-green);
}

.metrics-grid .metric-card.orange .metric-icon-small {
    color: #ffffff;
}

.metrics-grid .metric-card.red .metric-icon-small {
    color: var(--accent-red);
}

/* Upload Section */
.upload-section {
    background: var(--glass-bg);
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    margin-bottom: 2.5rem;
    transition: all 0.3s ease;
}

.upload-section:hover {
    border-color: var(--primary-blue);
    background: rgba(0, 86, 179, 0.05);
}

.btn-upload {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #2563eb 100%);
    color: white;
    padding: 1rem 3rem;
    border-radius: 50px;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
    margin-bottom: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.progress-container {
    max-width: 400px;
    margin: 0 auto;
    display: none;
    /* Hidden by default */
}

.progress-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-green);
    width: 0%;
    transition: width 0.3s ease;
}

/* Table Section */
.table-container {
    background: var(--glass-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    overflow-x: auto;
    /* Responsive tables */
}

.table-header {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Ensure table doesn't shrink too much */
}

.custom-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    font-weight: 500;
}

.custom-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-white);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
}

.status-inactive {
    background: rgba(225, 29, 72, 0.15);
    color: var(--accent-red);
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.action-btn.edit {
    color: var(--primary-blue);
}

.action-btn.delete {
    color: var(--accent-red);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Pagination Controls */
#pageInfo,
#pageIndicator {
    color: var(--text-white);
    font-weight: 500;
}

#prevBtn,
#nextBtn {
    color: var(--text-white);
    font-size: 0.9rem;
    padding: 8px 12px;
}

#prevBtn:disabled,
#nextBtn:disabled {
    color: var(--text-muted);
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Filter and Export Buttons (Standardized) --- */
.btn-filter {
    height: 40px;
    padding: 0 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-gen {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
    border: none;
}

.btn-gen:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.3);
}

.btn-clear {
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
}

.btn-clear:hover {
    background: rgba(148, 163, 184, 0.2);
    color: white;
}

.btn-excel {
    background: #15803d !important;
    color: white !important;
    border: none !important;
}

.btn-excel:hover {
    background: #166534 !important;
    transform: translateY(-1px);
}

.btn-blue {
    background: rgba(59, 130, 246, 0.1) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    color: #fff !important;
}

.btn-blue:hover {
    background: rgba(59, 130, 246, 0.2) !important;
    transform: translateY(-1px);
    border-color: rgba(59, 130, 246, 0.5) !important;
}

.btn-pdf {
    background: #b91c1c !important;
    color: white !important;
    border: none !important;
}

.btn-pdf:hover {
    background: #991b1b !important;
    transform: translateY(-1px);
}

/* Sidebar Toggle Button */
#menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.5rem;
    cursor: pointer;
    margin-bottom: 1rem;
}

/* --- Role-based Visibility (Prevent Flicker) --- */
/* By default, hide restricted items */
.only-superadmin,
.only-gestor-admin,
.only-non-auditor {
    display: none !important;
}

/* Show based on html class (set by inline script) */
html.role-superadmin .only-superadmin,
html.role-superadmin .only-non-auditor {
    display: block !important;
}

/* Gestor can see non-auditor items */
html.role-gestor .only-non-auditor {
    display: block !important;
}

/* Auditor can't see non-auditor items (already hidden by default above) */

/* Special case for sidebar flex items */
html.role-superadmin .nav-item.only-superadmin {
    display: list-item !important;
}

/* Media Query for Mobile Responsiveness */
@media (max-width: 768px) {
    .login-card {
        width: 95%;
        /* 95% width on mobile */
        padding: 2rem;
        /* Reduced padding */
        margin: 0 auto;
    }

    /* Sidebar Mobile Styles */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 250px;
        transform: translateX(-100%);
        z-index: 999;
        /* Force solid dark background with slight transparency for readability */
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Show Toggle Button - Fixed Position */
    #menu-toggle {
        display: block;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1001;
        /* Above sidebar overlay but below sidebar itself if needed */
        background: rgba(15, 23, 42, 0.8);
        padding: 10px;
        border-radius: 8px;
        backdrop-filter: blur(5px);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }

    /* Adjust Main Content padding to account for fixed button */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
        padding: 1.5rem;
        padding-top: 5rem;
        /* Extra space for the fixed button/header */
    }

    /* Tabs Navigation Responsive */
    .tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        margin: 1rem 0;
        border-bottom: 1px solid #334155;
    }

    .tabs-nav::-webkit-scrollbar {
        height: 4px;
    }

    .tabs-nav::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
    }

    .tabs-nav::-webkit-scrollbar-thumb {
        background: var(--primary-blue);
        border-radius: 2px;
    }

    .tab-btn {
        flex: 0 0 auto;
        /* Don't shrink */
        white-space: nowrap;
        font-size: 0.9rem;
    }

    .top-header {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
        padding-bottom: 1rem;
    }

    .page-title {
        font-size: 1.2rem;
        flex: 1 1 auto;
        margin-right: 10px;
        order: 1;
    }

    .user-profile {
        order: 2;
        padding: 5px 10px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 50px;
    }

    /* Toolbar Responsivo */
    .toolbar-container>div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }

    .toolbar-container div[style*="justify-content: center"] {
        flex-direction: column !important;
        max-width: none !important;
    }

    .toolbar-container .btn-filter {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Table Header Responsivo */
    .table-container>div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    .table-header {
        width: 100%;
        margin-bottom: 0 !important;
    }

    .table-container div[style*="display: flex; gap: 10px; align-items: center"] {
        width: 100%;
        justify-content: space-between !important;
        background: rgba(0, 0, 0, 0.2);
        padding: 10px;
        border-radius: 8px;
    }

    /* Overlay for when menu is open */
    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        display: none;
        backdrop-filter: blur(2px);
    }

    .menu-overlay.active {
        display: block;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
        padding-top: 4.5rem;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .user-profile span {
        display: none;
        /* Hide name on very small screens, keep avatar */
    }

    .toolbar-container {
        padding: 1rem !important;
    }

    .custom-table th:nth-child(4),
    .custom-table td:nth-child(4),
    .custom-table th:nth-child(5),
    .custom-table td:nth-child(5),
    .custom-table th:nth-child(6),
    .custom-table td:nth-child(6),
    .custom-table th:nth-child(7),
    .custom-table td:nth-child(7) {
        display: none;
        /* Hide less important columns on mobile */
    }
}

/* SweetAlert Z-Index Override */
.swal2-container {
    z-index: 10000 !important;
}

/* --- MODAL STYLES --- */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    width: 500px;
    max-width: 95%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-white);
}

.tab-btn.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

/* New Pill Tabs for Profile */
.modal-tabs .tab-btn {
    border-bottom: none !important;
    color: var(--text-muted);
}

.modal-tabs .tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.modal-tabs .tab-btn.active {
    background: #3b82f6 !important;
    /* Blue Vivid */
    color: white !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transform: scale(1.02);
}

.modal-tabs .tab-btn:active {
    transform: scale(0.98);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Modal Layout Adjustments for Header/Body/Footer */
.modal-content.fixed-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: 90vh;
}

.modal-content.fixed-layout .modal-header {
    flex-shrink: 0;
    padding: 1.5rem 2rem;
    text-align: center;
    position: relative;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.modal-content.fixed-layout .modal-header.blue {
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
}

.modal-content.fixed-layout .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.modal-content.fixed-layout .modal-footer {
    flex-shrink: 0;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-confirm {
    background: #8BC34A;
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-confirm:hover {
    background: #7CB342;
    transform: translateY(-1px);
}

.btn-cancel {
    background: #DC2626;
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-cancel:hover {
    background: #B91C1C;
    transform: translateY(-1px);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}


/* Badge Counter Styles */
.badge-counter {
    background: var(--primary-blue);
    color: white;
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 50px;
    margin-left: 10px;
    vertical-align: middle;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Cards Container for Configuration */
.cards-container {
    display: flex;
    gap: 20px;
    /* Espacio entre tarjetas */
    flex-wrap: wrap;
    /* Permite que caigan si no hay espacio */
}

.cards-container>div {
    flex: 1;
    /* Ocupan el mismo ancho */
    min-width: 300px;
    /* Si la pantalla es muy chica, saltará abajo */
}

/* Toggle Switch Styles */
.switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #2ecc71 !important;
    /* Verde Vibrante */
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
}

input:checked+.slider:before {
    transform: translateX(26px);
}


/* --- SweetAlert2 Dark Theme Glossy --- */
.swal2-popup {
    background: #1e293b !important;
    background: rgba(30, 41, 59, 1) !important;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 24px !important;
    color: #fff !important;
    font-family: 'Poppins', sans-serif !important;
}

.swal2-title {
    color: #fff !important;
    font-weight: 700 !important;
}

.swal2-html-container {
    color: rgba(255, 255, 255, 0.9) !important;
}

.swal2-confirm {
    background-color: #3b82f6 !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    padding: 12px 30px !important;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3) !important;
}

.swal2-cancel {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    color: #fff !important;
    font-weight: 600 !important;
}

.swal2-confirm:focus,
.swal2-cancel:focus {
    box-shadow: none !important;
}

.swal2-icon.swal2-question {
    border-color: #3b82f6 !important;
    color: #3b82f6 !important;
}

.swal2-icon.swal2-success {
    border-color: #22c55e !important;
    color: #22c55e !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border: .25em solid rgba(34, 197, 94, .3) !important;
}

.swal2-success-line-tip,
.swal2-success-line-long {
    background-color: #22c55e !important;
}

.swal2-icon.swal2-error {
    border-color: #ef4444 !important;
    color: #ef4444 !important;
}

.swal2-loader {
    border-color: #3b82f6 transparent #3b82f6 transparent !important;
}

/* --- SweetAlert Wide Modal Styles --- */
.swal-wide {
    width: 600px !important;
    max-width: 95% !important;
}

.swal-wide .swal2-html-container {
    max-height: 500px;
    overflow-y: auto;
}

/* Scrollbar para modales anchos */
.swal-wide .swal2-html-container::-webkit-scrollbar {
    width: 6px;
}

.swal-wide .swal2-html-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.swal-wide .swal2-html-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.swal-wide .swal2-html-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* --- Tab Transitions (Messaging page only) --- */
.msg-tab-content {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.msg-tab-content.tab-active {
    opacity: 1;
    transform: translateY(0);
}

/* Scheduled Messages responsive header */
@media (max-width: 768px) {
    #tab-scheduled>div:first-child {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start !important;
    }

    #tab-scheduled>div:first-child h3 {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    #tab-scheduled>div:first-child h3 {
        font-size: 0.85rem;
    }
}

/* --- Messaging System (Bandeja de Mensajes) --- */

/* Main 3-column horizontal layout */
.msg-layout {
    display: grid;
    grid-template-columns: 300px 1fr 260px;
    gap: 1.2rem;
    align-items: start;
}

/* Column containers */
.msg-col-config {
    min-width: 0;
}

.msg-col-composer {
    min-width: 0;
}

.msg-col-preview {
    position: sticky;
    top: 2rem;
    min-width: 0;
}

/* Audience Chips (compact horizontal) */
.audience-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.audience-chip {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
}

.audience-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.audience-chip i {
    font-size: 1rem;
    color: var(--text-muted);
    transition: all 0.25s ease;
}

.audience-chip:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.audience-chip.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    color: #e0eaff;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.15);
}

.audience-chip.selected i {
    color: #60a5fa;
}

/* Schedule Chips */
.schedule-chip {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    position: relative;
}

.schedule-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.schedule-chip i {
    font-size: 0.9rem;
}

.schedule-chip:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
}

.schedule-chip.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    color: #e0eaff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

/* Unicode Alert Banner */
.unicode-alert {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-left: 3px solid #f59e0b;
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 12px;
    animation: fadeSlideIn 0.3s ease-out;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smart SMS Counter Area */
.sms-counter-bar {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.counter-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.encoding-badge {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.encoding-badge.gsm {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.encoding-badge.unicode {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.sms-count-badge {
    font-size: 0.78rem;
    color: #60a5fa;
    font-weight: 700;
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 10px;
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Send Button */
.btn-send-main {
    width: 100%;
    margin-top: 16px;
    height: 48px;
    font-size: 1rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.btn-send-main:hover {
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.45);
    transform: translateY(-1px);
}

/* Phone Preview Mockup */
.phone-mockup {
    width: 230px;
    height: 400px;
    background: #0a0a0a;
    border: 6px solid #334155;
    border-radius: 28px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: #f8fafc;
    padding: 10px;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.phone-header {
    height: 30px;
    background: #e2e8f0;
    margin: -10px -10px 10px -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.5px;
}

.sms-bubble {
    background: #e2e8f0;
    color: #1e293b;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 10.5px;
    align-self: flex-start;
    max-width: 92%;
    line-height: 1.45;
    position: relative;
    border-bottom-left-radius: 2px;
    margin-bottom: 6px;
    word-break: break-word;
}

.sms-bubble::after {
    content: "";
    position: absolute;
    left: -3px;
    bottom: 0;
    width: 6px;
    height: 6px;
    background: #e2e8f0;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.sms-time {
    font-size: 9px;
    color: #94a3b8;
    margin-top: auto;
    text-align: center;
}

/* Progress indicator for SMS */
.char-progress-container {
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.char-progress-bar {
    height: 100%;
    background: #22c55e;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
}

.char-progress-bar.warning {
    background: #f59e0b;
}

.char-progress-bar.danger {
    background: #ef4444;
}

/* Section Cards */
.section-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 0;
}

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet / Medium screens */
@media (max-width: 1200px) {
    .msg-layout {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .msg-col-preview {
        grid-column: 1 / -1;
        position: static;
    }

    .msg-col-preview .phone-mockup {
        width: 200px;
        height: 350px;
    }

    .msg-col-preview {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        align-items: flex-start;
    }

    .msg-col-preview>.section-title {
        width: 100%;
    }

    .msg-col-preview>.phone-mockup {
        flex-shrink: 0;
    }

    .msg-col-preview>.section-card {
        flex: 1;
        min-width: 200px;
    }
}

/* Small tablets / Large phones */
@media (max-width: 768px) {
    .msg-layout {
        grid-template-columns: 1fr;
    }

    .audience-grid-compact {
        grid-template-columns: repeat(3, 1fr);
    }

    .msg-col-preview .phone-mockup {
        width: 180px;
        height: 320px;
    }

    .phone-mockup {
        border-width: 5px;
        border-radius: 22px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .audience-grid-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    .audience-chip {
        padding: 6px 4px;
        font-size: 0.68rem;
    }

    .schedule-chip {
        padding: 8px 10px;
        font-size: 0.72rem;
    }

    .msg-col-preview .phone-mockup {
        width: 160px;
        height: 280px;
    }

    .btn-send-main {
        height: 45px;
        font-size: 0.9rem;
    }

    .sms-counter-bar {
        margin-top: 8px;
    }

    .encoding-badge {
        font-size: 0.6rem;
        padding: 1px 5px;
    }

    .sms-count-badge {
        font-size: 0.72rem;
        padding: 2px 6px;
    }
}