/* Admin Panel - Minimalist Style */

:root {
    --color-bg: #ffffff;
    --color-bg-secondary: #fafafa;
    --color-text: #171717;
    --color-text-secondary: #737373;
    --color-text-muted: #a3a3a3;
    --color-border: #e5e5e5;
    --color-border-light: #f5f5f5;
    --color-accent: #171717;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 20px;
    --font-size-2xl: 28px;
    --radius: 4px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --transition: 0.15s ease;
}

/* Dark Mode */
[data-theme="dark"] {
    --color-bg: #0a0a0a;
    --color-bg-secondary: #141414;
    --color-text: #f5f5f5;
    --color-text-secondary: #a3a3a3;
    --color-text-muted: #737373;
    --color-border: #2a2a2a;
    --color-border-light: #1f1f1f;
    --color-accent: #f5f5f5;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
}

/* Transición suave entre temas */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
    transition: background-color 300ms ease, 
                color 300ms ease, 
                border-color 300ms ease,
                box-shadow 300ms ease !important;
}

/* Estilos para iconos de tema */
.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

[data-theme="dark"] .icon-sun {
    display: block;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

/* Botón de tema en header */
#theme-toggle.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--color-text);
    transition: background var(--transition);
}

#theme-toggle.btn-icon:hover {
    background: var(--color-bg-secondary);
}

#theme-toggle.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Theme Toggle Button flotante (fallback) */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 200ms ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: var(--color-text-muted);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.15);
}

[data-theme="dark"] .theme-toggle:focus {
    box-shadow: 0 0 0 3px rgba(245, 245, 245, 0.2);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--color-text);
    transition: transform 300ms ease, opacity 200ms ease;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 320px;
}

.login-box h1 {
    font-size: var(--font-size-xl);
    font-weight: 500;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: 32px;
}

.login-note {
    margin-top: 24px;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-align: center;
}

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

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: 6px;
    font-weight: 400;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-text);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
}

.form-value {
    padding: 10px 0;
    font-size: var(--font-size-base);
    color: var(--color-text);
    font-weight: 500;
    margin: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
    cursor: pointer;
}

.form-section-title {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: 16px;
}

.error-message {
    color: var(--color-error);
    font-size: var(--font-size-sm);
    margin-bottom: 16px;
    min-height: 20px;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 10px 16px;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    font-weight: 500;
    color: var(--color-bg);
    background: var(--color-text);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity var(--transition);
}

.btn-primary:hover {
    opacity: 0.85;
}

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

.btn-text {
    padding: 6px 12px;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    font-weight: 400;
    color: var(--color-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition);
}

.btn-text:hover {
    color: var(--color-text);
}

.btn-text.btn-danger {
    color: var(--color-error);
}

.btn-text.btn-danger:hover {
    color: #dc2626;
}

.btn-sm {
    padding: 4px 8px;
    font-size: var(--font-size-xs);
}

.btn-close {
    width: 28px;
    height: 28px;
    font-size: 18px;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: var(--color-text);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-left h1 {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.badge-superadmin {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-bg-secondary);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-weight: 400;
}

.nav {
    display: flex;
    gap: 4px;
}

.nav-item {
    padding: 8px 12px;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.nav-item:hover {
    color: var(--color-text);
    background: var(--color-bg-secondary);
}

.nav-item.active {
    color: var(--color-text);
    background: var(--color-bg-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-input {
    padding: 6px 12px;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: 200px;
    background: var(--color-bg);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-text);
}

.user-email {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* Content */
.content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 500;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Select */
.select {
    padding: 6px 28px 6px 12px;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23737373' d='M3 4.5L6 8l3-3.5H3z'/%3E%3C/svg%3E") no-repeat right 8px center;
    appearance: none;
    cursor: pointer;
}

.select:focus {
    outline: none;
    border-color: var(--color-text);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-sub {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Live Chart */
.live-chart-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    background: var(--color-bg);
    overflow: hidden;
}

.live-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.live-chart-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.live-indicator {
    width: 6px;
    height: 6px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.live-chart-stats {
    display: flex;
    gap: 20px;
}

.chart-stat {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.chart-stat-value {
    font-size: var(--font-size-lg);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.chart-stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

#liveChart {
    width: 100%;
    height: 80px;
    display: block;
}

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* Card */
.card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
    font-size: var(--font-size-base);
    font-weight: 500;
}

.card-body {
    padding: 16px 20px;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
}

.table td {
    padding: 12px;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--color-bg-secondary);
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: 99px;
    text-transform: lowercase;
}

.badge-active {
    color: var(--color-success);
    background: rgba(34, 197, 94, 0.1);
}

.badge-inactive {
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
}

.badge-warning {
    color: var(--color-warning);
    background: rgba(245, 158, 11, 0.1);
}

.badge-trial {
    color: var(--color-warning);
    background: rgba(245, 158, 11, 0.1);
}

.badge-plan {
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
}

.badge-success {
    color: var(--color-success);
    background: rgba(34, 197, 94, 0.1);
}

.badge-danger {
    color: var(--color-error);
    background: rgba(239, 68, 68, 0.1);
}

.badge-info {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}


/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-light);
}

.pagination button {
    padding: 6px 10px;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--color-text-secondary);
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--color-text);
    color: var(--color-text);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination span {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.pagination-info {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* Bulk Actions */
.bulk-actions {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    background: var(--color-text);
    color: var(--color-bg);
    border-radius: var(--radius);
    display: none;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.bulk-actions.show {
    display: flex;
}

.bulk-actions button {
    color: rgba(255,255,255,0.8);
}

.bulk-actions button:hover {
    color: #fff;
}

/* Activity Feed */
.activity-feed {
    display: flex;
    flex-direction: column;
}

.activity-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

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

.activity-item.activity-critical {
    background: rgba(239, 68, 68, 0.05);
    margin: 0 -20px;
    padding: 12px 20px;
}

.activity-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-border);
    margin-top: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--color-text-muted);
}

.activity-dot.green { 
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.activity-dot.yellow { 
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
}

.activity-dot.red { 
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.activity-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

.activity-details {
    color: var(--color-text-secondary);
}

.activity-count {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    padding: 4px 10px;
    border-radius: var(--radius);
    flex-shrink: 0;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--color-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.modal-content.modal-lg {
    max-width: 720px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

.modal-footer .btn-primary {
    width: auto;
}

.divider {
    height: 1px;
    background: var(--color-border);
    margin: 20px 0;
}

/* Text utilities */
.text-muted {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.text-success {
    color: var(--color-success);
}

.text-error {
    color: var(--color-error);
}

/* Progress bars (for plan breakdown) */
.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-row:last-child {
    margin-bottom: 0;
}

.progress-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    width: 80px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--color-border-light);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-text);
    border-radius: 3px;
}

.progress-value {
    font-size: var(--font-size-sm);
    font-weight: 500;
    width: 40px;
    text-align: right;
}

/* Stats inline */
.stats-inline {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-inline {
    text-align: center;
    padding: 12px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius);
}

.stat-inline-value {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.stat-inline-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: 2px;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    background: var(--color-text);
    color: var(--color-bg);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    animation: slideIn 0.2s ease;
}

.toast.success {
    background: var(--color-success);
}

.toast.error {
    background: var(--color-error);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Checkbox */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
}

/* Loading */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 12px;
    }
    
    .header-left {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-input {
        flex: 1;
    }
    
    .nav {
        width: 100%;
        overflow-x: auto;
    }
    
    .content {
        padding: 16px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

.textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    resize: vertical;
    transition: border-color var(--transition);
}

.textarea:focus {
    outline: none;
    border-color: var(--color-text);
}

.textarea::placeholder {
    color: var(--color-text-muted);
}

.status-indicator { width: 8px; height: 8px; border-radius: 50%; position: absolute; top: 12px; right: 12px; } .status-indicator.status-online { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,0.1); } .status-indicator.status-warning { background: #f59e0b; } .status-indicator.status-error { background: #ef4444; } .monitor-detail { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f5f5f5; } .monitor-label { font-size: 13px; color: #737373; } .monitor-value { font-size: 13px; color: #171717; font-weight: 500; } .system-alert { display: flex; gap: 12px; padding: 12px; margin-bottom: 8px; background: #fafafa; border-left: 3px solid #e5e5e5; } .system-alert.alert-error { background: rgba(239,68,68,0.05); border-left-color: #ef4444; } .alert-content { flex: 1; } .alert-title { font-size: 13px; font-weight: 500; } .alert-message { font-size: 11px; color: #737373; } .alert-time { font-size: 11px; color: #a3a3a3; }
