/* Estilos específicos para el panel de administrador */
.admin-body {
    background: #f8fafc;
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: 250px 1fr;
    grid-template-rows: 70px 1fr;
    min-height: 100vh;
}

/* Header del Administrador */
.admin-header {
    grid-area: header;
    background: #1e293b;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 100%;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-logo img {
    height: 40px;
    width: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.admin-logo i {
    font-size: 20px;
    color: #f59e0b;
}

.admin-logo h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

#adminUserName {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
}

#adminUserName i {
    color: #f59e0b;
    font-size: 16px;
}

.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Sidebar */
.admin-sidebar {
    grid-area: sidebar;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    padding: 24px 0;
}

.admin-menu {
    display: flex;
    flex-direction: column;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.menu-item.active {
    background: #eff6ff;
    color: #2563eb;
    border-left-color: #2563eb;
}

.menu-item i {
    width: 18px;
    text-align: center;
}

/* Contenido Principal */
.admin-main {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.section-header p {
    color: #64748b;
    margin: 4px 0 0 0;
}

/* Tarjetas de Estadísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.stat-card:nth-child(1) .stat-icon {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.stat-card:nth-child(2) .stat-icon {
    background: linear-gradient(135deg, #10b981, #059669);
}

.stat-card:nth-child(3) .stat-icon {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.stat-card:nth-child(4) .stat-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.stat-info p {
    color: #64748b;
    margin: 4px 0 0 0;
    font-size: 14px;
}

/* Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.chart-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 16px 0;
}

.chart-placeholder {
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    background: #f8fafc;
    border-radius: 8px;
    border: 2px dashed #cbd5e1;
}

.chart-placeholder i {
    font-size: 48px;
    margin-bottom: 12px;
}

/* Tablas */
.table-container {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    background: #f8fafc;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e2e8f0;
}

.admin-table td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
}

.admin-table tr:hover {
    background: #f9fafb;
}

.no-data {
    text-align: center;
    color: #94a3b8;
    font-style: italic;
}

/* Filtros */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

/* Reportes */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.report-card {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    text-align: center;
}

.report-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 8px 0;
}

.report-card p {
    color: #64748b;
    margin: 0 0 16px 0;
    font-size: 14px;
}

/* Configuración */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.setting-card {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.setting-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 16px 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.setting-item label {
    font-weight: 500;
    color: #374151;
}

.setting-item input {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    width: 100px;
}

.status-indicator {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.connected {
    background: #dcfce7;
    color: #166534;
}

.status-indicator.disconnected {
    background: #fee2e2;
    color: #991b1b;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 24px;
    padding-bottom: 0;
}

.settings-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    border-radius: 6px 6px 0 0;
}

.settings-tab:hover {
    color: #334155;
    background: #f8fafc;
}

.settings-tab.active {
    color: #F26522;
    border-bottom-color: #F26522;
    font-weight: 600;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* Orphaned Accounts Panel */
.orphaned-accounts-panel {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.orphaned-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.orphaned-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.orphaned-info p {
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.btn-analyze {
    padding: 10px 20px;
    background: #F26522;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-analyze:hover {
    background: #D4541E;
}

.btn-analyze:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.orphaned-status {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.orphaned-status.loading {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0369a1;
}

.orphaned-status.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.orphaned-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.orphaned-summary .summary-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.orphaned-summary .summary-item strong {
    color: #1e293b;
    font-size: 1.1rem;
}

.orphaned-summary .summary-item span {
    color: #64748b;
}

.orphaned-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

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

.orphaned-table thead th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.orphaned-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.orphaned-table tbody tr:hover {
    background: #fafbfc;
}

.orphaned-table .uid-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #64748b;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orphaned-table .provider-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.btn-delete-orphan {
    padding: 6px 14px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-delete-orphan:hover {
    background: #fca5a5;
    color: #7f1d1d;
}

.btn-delete-orphan:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.orphaned-empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.orphaned-empty i {
    font-size: 2.5rem;
    color: #10b981;
    margin-bottom: 12px;
    display: block;
}

.orphaned-empty p {
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .settings-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .settings-tab {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .orphaned-header {
        flex-direction: column;
    }

    .btn-analyze {
        width: 100%;
        justify-content: center;
    }

    .orphaned-summary {
        flex-direction: column;
    }
}

/* Logs */
.logs-container {
    background: #1e293b;
    border-radius: 8px;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
}

.log-entry {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
}

.log-time {
    color: #94a3b8;
    min-width: 140px;
}

.log-level {
    min-width: 50px;
    font-weight: 600;
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.log-level.info {
    background: #3b82f6;
    color: #fff;
}

.log-level.warning {
    background: #f59e0b;
    color: #fff;
}

.log-level.error {
    background: #ef4444;
    color: #fff;
}

.log-message {
    color: #e2e8f0;
    flex: 1;
}

/* Botones */
.btn-secondary {
    background: #f8fafc;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #9ca3af;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .admin-body {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 70px 1fr;
    }
    
    .admin-sidebar {
        position: fixed;
        left: -250px;
        top: 70px;
        height: calc(100vh - 70px);
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .admin-sidebar.open {
        left: 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-main {
        padding: 16px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .filters {
        flex-wrap: wrap;
    }
    
    .admin-table {
        font-size: 14px;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 12px 8px;
    }
}

/* Estilos para Gestión de Tasas */
.rates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.rate-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.rate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.rate-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.rate-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rate-status.active {
    background: #dcfce7;
    color: #166534;
}

.rate-status.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.rate-content {
    padding: 16px 24px 24px;
}

.rate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.rate-item:last-child {
    border-bottom: none;
}

.currency-pair {
    font-weight: 500;
    color: #374151;
}

.rate-value {
    font-weight: 600;
    color: #1e293b;
    font-size: 1.1rem;
}

.btn-edit {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.btn-edit:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #9ca3af;
}

.btn-edit i {
    font-size: 14px;
}

.rates-table-container {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.rates-table-container h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

/* Responsive para Gestión de Tasas */
@media (max-width: 768px) {
    .rates-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .rate-header {
        padding: 16px 20px;
    }
    
    .rate-content {
        padding: 12px 20px 20px;
    }
    
    .rate-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .btn-edit {
        align-self: flex-end;
    }
}

/* ===================================
   PROGRAMS & COMMISSIONS SECTION
   =================================== */
.programs-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.program-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #e2e8f0;
}

.program-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.program-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.program-header h3 i {
    color: #6366f1;
}

.program-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.program-badge.europa {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.program-badge.latam {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.memberships-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.membership-edit-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.membership-edit-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #6366f1;
}

.membership-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #cbd5e1;
}

.membership-name i {
    color: #f59e0b;
}

.edit-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.edit-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.edit-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.commission-input,
.price-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: white;
}

.commission-input {
    color: #f59e0b;
}

.price-input {
    color: #6366f1;
}

.commission-input:focus,
.price-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.save-program-btn {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.save-program-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

@media (max-width: 768px) {
    .memberships-grid {
        grid-template-columns: 1fr;
    }
    
    .program-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .program-card {
        padding: 1.5rem;
    }
}
