:root {
    --primary: #810000;
    --primary-hover: #a80000;
    --sidebar-bg: #1A1C1E;
    --bg-body: #F4F7F6;
    --bg-card: #FFFFFF;
    --text-primary: #1E2022;
    --text-secondary: #52616B;
    --text-muted: #9BA4B5;
    --border: #E1E8EB;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    overflow: hidden;
}

.admin-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 30px;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header i {
    color: var(--primary);
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 30px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#btn-logout {
    width: 100%;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

#btn-logout:hover {
    background-color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-bar {
    background-color: var(--bg-card);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#admin-email {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.admin-badge {
    padding: 4px 10px;
    background-color: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.content-body {
    padding: 40px;
}

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

.dashboard-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
    height: 350px;
}

@media (max-width: 1024px) {
    .dashboard-charts {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.chart-card {
    padding: 15px;
    background: var(--bg-card);
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--text-dark);
}

.chart-card canvas {
    flex: 1;
    max-height: 280px;
}

.stat-card {
    background-color: var(--bg-card);
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 54px;
    height: 54px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
}

.stat-data h3 {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-data p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Sections */
.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.card {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-container {
    min-height: 200px;
}

.list-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.list-container::-webkit-scrollbar {
    width: 6px;
}

.list-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 0;
    font-style: italic;
}

/* Tabs */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tables */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admin-table th {
    text-align: left;
    padding: 15px;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 600;
}

.admin-table td {
    padding: 18px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

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

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.severity-info {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.badge.severity-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fef3c7;
}

.badge.severity-error {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.badge.severity-critical {
    background: #450a0a;
    color: #fecdd3;
    border: 1px solid #7f1d1d;
}

.log-details {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: help;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

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

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

/* Affiliate specific */
.status-paid {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

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

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

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
}

.section-header {
    margin-bottom: 30px;
}

.section-header p {
    color: var(--text-secondary);
    margin-top: 5px;
}

.editable-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    width: 100%;
}

.btn-save-row {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
}

/* Header with Action */
.header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

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

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    background: white;
}

.input-color-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 5px 12px;
}

.input-color-wrapper input[type="color"] {
    width: 50px;
    height: 35px;
    padding: 0;
    border: none;
    cursor: pointer;
    background: none;
}

/* Plan Selection Group */
.plan-selection-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.plan-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.plan-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch input:checked+.slider {
    background-color: var(--success);
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(20px);
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

/* Badge variants */
.section-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* --- Invoice History Table (Premium) --- */
#admin-invoice-list {
    max-height: 450px;
    overflow-y: auto;
    padding-right: 5px;
    margin-top: 15px;
}

/* Scrollbar personalizado para el panel admin */
#admin-invoice-list::-webkit-scrollbar {
    width: 6px;
}

#admin-invoice-list::-webkit-scrollbar-track {
    background: transparent;
}

#admin-invoice-list::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.invoice-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.invoice-table th {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding: 12px;
    font-size: 0.8rem;
    color: #64748b;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.invoice-table td {
    padding: 12px;
    background: #f8fafc;
    vertical-align: middle;
}

.invoice-table tr td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.invoice-table tr td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.invoice-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.invoice-table tbody tr {
    background: var(--bg-card);
    transition: transform 0.2s, box-shadow 0.2s;
}

.invoice-table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.invoice-table td {
    padding: 16px;
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.invoice-table td:first-child {
    border-left: 1px solid var(--border);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.invoice-table td:last-child {
    border-right: 1px solid var(--border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-paid {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-pending {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* Icon Button */
.btn-invoice-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f0f0f0;
    color: var(--primary);
    transition: all 0.2s;
    text-decoration: none;
}

.btn-invoice-download:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

/* --- Gestión de Usuarios Avanzada --- */

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    font-size: 0.9rem;
    color: #475569;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-select:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.user-detail-header {
    margin-bottom: 15px;
}

.user-detail-header p {
    margin: 5px 0;
}

.danger-zone {
    margin-top: 25px;
    padding: 15px;
    background: #fff5f5;
    border-radius: 12px;
    border: 1px solid #feb2b2;
}

.danger-zone h3 {
    font-size: 0.9rem;
    color: #c53030;
    margin-bottom: 10px;
}

.btn-outline-danger {
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #fc8181;
    background: white;
    color: #c53030;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}


.btn-outline-danger:hover {
    background: #fff5f5;
    border-color: #e53e3e;
}

/* Quill HTML Editor Mode Styles */
#q-html-editor {
    display: none;
    width: 100%;
    height: 200px;
    padding: 12px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    background-color: #f8f9fa;
    color: #333;
    border: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
    resize: vertical;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

#q-html-editor:focus {
    border-color: var(--primary);
}

.ql-code-block {
    color: #444 !important;
}

.ql-code-block:hover {
    color: var(--primary) !important;
}

/* Moderación Styles */
.moderation-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    margin-top: 20px;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid #e53e3e;
    color: #e53e3e;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline-danger:hover {
    background: #e53e3e;
    color: white;
}

#review-content code {
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    line-height: 1.6;
    color: #1e293b;
}

.text-muted {
    color: #64748b !important;
    font-size: 0.85rem !important;
}

/* Marketing Styles */
.segment-labels {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.badge-plan {
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    text-transform: uppercase;
}

.status-badge.status-draft {
    background: #f1f5f9;
    color: #64748b;
}

.status-badge.status-queued {
    background: #e0f2fe;
    color: #0369a1;
}

.status-badge.status-sending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-completed {
    background: #dcfce7;
    color: #166534;
}

.status-badge.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.mini-progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.mini-progress-bar .fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

#campaign-editor textarea {
    display: none;
    border: none;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #334155;
    background: #f8fafc;
    width: 100%;
    height: 100%;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.fa-spin {
    animation: spin 1s infinite linear;
}

.btn-icon.danger:hover {
    background: var(--danger);
    color: white;
}

/* Fix Quill Container & Textarea */
#campaign-editor-container {
    background: white;
}

#campaign-editor.ql-container {
    height: 500px !important;
    display: flex !important;
    flex-direction: column !important;
    border: none !important;
    overflow: hidden !important;
}

#campaign-editor .ql-editor {
    height: 100% !important;
    min-height: 500px !important;
    overflow-y: auto !important;
    background: white !important;
    cursor: text !important;
}

.campaign-html-textarea {
    display: block !important;
    width: 100% !important;
    height: 500px !important;
    border: none !important;
    padding: 20px !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    background: #f1f5f9 !important;
    color: #1e293b !important;
    outline: none !important;
    resize: none !important;
    z-index: 10 !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.editor-actions-bar {
    background: white;
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

#dashboard-marketplace-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.mkt-stat-item {
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.mkt-stat-item h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.mkt-stat-item span {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.btn-delete-row {
    background: #fff5f5;
    color: var(--danger);
    border: 1px solid #ffe3e3;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-row:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Paginación */
.pagination-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 25px;
}

.pagination-container button {
    min-width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-container button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-container button.active,
.pagination-container button.btn-primary {
    background: var(--primary);
    color: white !important;
    border-color: var(--primary);
}

/* Configuración Global */
#affiliate-global-config {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(129, 0, 0, 0.1);
}

/* Sub-tabs Marketplace */
.sub-tabs-container {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.sub-tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 10px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sub-tab-btn i {
    margin-right: 8px;
}

.sub-tab-btn:hover {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
}

.sub-tab-btn.active {
    background: var(--primary);
    color: white;
}

.sub-tab-pane {
    display: none;
}

.sub-tab-pane.active {
    display: block;
    animation: fadeInSub 0.3s ease;
}

@keyframes fadeInSub {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-input-sm {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
}

.btn-primary-sm {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
}

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

.table-responsive {
    width: 100%;
    overflow-x: auto;
}/* ========================================
   REVENUE ANALYTICS PANEL
   ======================================== */

.revenue-analytics-panel {
    margin-bottom: 30px;
}

/* Filtros */
.analytics-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 18px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-btn:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}

.filter-btn.active {
    background: var(--primary, #800020);
    color: white;
    border-color: var(--primary, #800020);
}

#custom-date-range {
    display: none;
    gap: 10px;
    align-items: center;
    padding: 8px;
    background: #f8f8f8;
    border-radius: 8px;
}

#custom-date-range input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn-primary-small {
    padding: 8px 16px;
    background: var(--primary, #800020);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary-small:hover {
    opacity: 0.9;
}

/* Highlights Cards */
.analytics-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.highlight-card {
    background: linear-gradient(135deg, var(--primary, #800020) 0%, #5a0015 100%);
    padding: 25px;
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.highlight-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.highlight-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.highlight-data h3 {
    font-size: 2rem;
    margin: 0 0 5px 0;
    font-weight: 700;
}

.highlight-data p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

.highlight-data small {
    opacity: 0.7;
    font-size: 0.85rem;
}

/* Plans Revenue Grid */
.plans-revenue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    min-height: 100px;
}

.plan-revenue-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s;
}

.plan-revenue-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
    border-color: var(--primary, #800020);
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f5f5f5;
}

.plan-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.plan-badge {
    background: #f0f0f0;
    color: var(--primary, #800020);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.plan-metrics {
    display: flex;
    gap: 20px;
}

.plan-metrics .metric {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.plan-metrics .metric i {
    font-size: 1.5rem;
    color: var(--primary, #800020);
    opacity: 0.8;
}

.metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.metric-label {
    display: block;
    font-size: 0.85rem;
    color: #999;
}

.loading-placeholder {
    text-align: center;
    padding: 40px;
    color: #999;
    grid-column: 1 / -1;
}

.loading-placeholder i {
    font-size: 2rem;
    margin-bottom: 10px;
}

.loading-placeholder p {
    margin: 0;
    font-size: 0.95rem;
}

.empty-msg {
    text-align: center;
    padding: 40px;
    color: #999;
    grid-column: 1 / -1;
}

/* Dark mode support */
html[data-theme="dark"] .filter-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #fff;
}

html[data-theme="dark"] .filter-btn:hover {
    background: #333;
}

html[data-theme="dark"] #custom-date-range {
    background: #2a2a2a;
}

html[data-theme="dark"] #custom-date-range input[type="date"] {
    background: #333;
    border-color: #444;
    color: #fff;
}

html[data-theme="dark"] .plan-revenue-card {
    background: #2a2a2a;
    border-color: #444;
}

html[data-theme="dark"] .plan-header h4,
html[data-theme="dark"] .metric-value {
    color: #fff;
}

html[data-theme="dark"] .plan-header {
    border-bottom-color: #333;
}

html[data-theme="dark"] .plan-badge {
    background: #444;
    color: #fff;
}

html[data-theme="dark"] .highlight-card {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .analytics-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-btn {
        justify-content: center;
    }
    
    .analytics-highlights {
        grid-template-columns: 1fr;
    }
    
    .plans-revenue-grid {
        grid-template-columns: 1fr;
    }
    
    #custom-date-range {
        flex-direction: column;
        align-items: stretch;
    }
}
/* ========================================
   MARKETPLACE ANALYTICS PANEL
   ======================================== */

.marketplace-analytics-panel {
    margin-bottom: 30px;
}

/* Marketplace Metrics Grid */
.marketplace-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.metric-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.metric-card .metric-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.metric-card .metric-data h3 {
    font-size: 1.8rem;
    margin: 0 0 5px 0;
    font-weight: 700;
}

.metric-card .metric-data p {
    margin: 0 0 3px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.metric-card .metric-data small {
    color: #999;
    font-size: 0.8rem;
}

/* Colores específicos por tipo de métrica */
.metric-card.platform-earnings {
    border-left: 4px solid #10b981;
}

.metric-card.platform-earnings .metric-icon {
    color: #10b981;
}

.metric-card.sellers-earnings {
    border-left: 4px solid #3b82f6;
}

.metric-card.sellers-earnings .metric-icon {
    color: #3b82f6;
}

.metric-card.paid-out {
    border-left: 4px solid #8b5cf6;
}

.metric-card.paid-out .metric-icon {
    color: #8b5cf6;
}

.metric-card.total-sales {
    border-left: 4px solid #f59e0b;
}

.metric-card.total-sales .metric-icon {
    color: #f59e0b;
}

/* Dark mode para marketplace metrics */
html[data-theme="dark"] .metric-card {
    background: #2a2a2a;
    border-color: #444;
}

html[data-theme="dark"] .metric-card .metric-data p {
    color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .marketplace-metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-card {
        flex-direction: column;
        text-align: center;
    }
}
/* ========================================
/* ========================================
/* Panel principal */
.marketplace-analytics-panel {
    margin-bottom: 15px;
}

.marketplace-analytics-panel .analytics-filters {
    margin-bottom: 10px;
}

/* Grid MUY compacto - 2 filas de 2 */
.marketplace-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

/* Cards MUCHO más pequeñas */
.metric-card {
    padding: 10px 12px;
    gap: 10px;
    flex-direction: row;
    align-items: center;
}

.metric-card .metric-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.metric-card .metric-data {
    flex: 1;
}

.metric-card .metric-data h3 {
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.2;
}

.metric-card .metric-data p {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
}

.metric-card .metric-data small {
    display: none; /* Ocultar subtítulos para ahorrar espacio */
}

/* Responsive - en móvil 1 columna */
@media (max-width: 768px) {
    .marketplace-metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   MARKETPLACE ANALYTICS - VERSIÓN FINAL COMPACTA
   ======================================== */

/* Ocultar header innecesario */
.sub-tab-pane > .stats-grid:first-of-type {
    margin-top: 5px !important;
}

/* Panel principal - muy compacto */
.marketplace-analytics-panel {
    margin-bottom: 10px;
}

.marketplace-analytics-panel .analytics-filters {
    margin-bottom: 8px;
}

/* Grid de 3 columnas compactas */
.marketplace-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

/* Cards horizontales y MUY compactas */
.metric-card {
    padding: 8px 10px;
    gap: 8px;
    flex-direction: row;
    align-items: center;
    min-height: auto;
}

.metric-card .metric-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 30px;
}

.metric-card .metric-data {
    flex: 1;
}

.metric-card .metric-data h3 {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.1;
}

.metric-card .metric-data p {
    margin: 0;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.2;
}

.metric-card .metric-data small {
    display: none;
}

/* Sección de comisiones 75% más pequeña */
.marketplace-analytics-panel + .stats-grid + .card {
    padding: 8px 12px !important;
    margin-bottom: 10px !important;
}

.marketplace-analytics-panel + .stats-grid + .card h3 {
    font-size: 0.85rem !important;
    margin-bottom: 6px !important;
}

.marketplace-analytics-panel + .stats-grid + .card .form-grid {
    gap: 8px !important;
    margin-top: 6px !important;
}

.marketplace-analytics-panel + .stats-grid + .card .form-group label {
    font-size: 0.7rem !important;
    margin-bottom: 2px !important;
}

.marketplace-analytics-panel + .stats-grid + .card .form-group input {
    padding: 4px 6px !important;
    font-size: 0.8rem !important;
}

.marketplace-analytics-panel + .stats-grid + .card button {
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
}

/* Responsive */
@media (max-width: 768px) {
    .marketplace-metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   MARKETPLACE ANALYTICS - AUMENTAR ALTO 70%
   ======================================== */

/* Aumentar alto de metric cards 70% */
.metric-card {
    padding: 14px 12px !important;    /* Antes: 8px 10px */
    min-height: 65px;                 /* Fija altura mínima */
}

.metric-card .metric-icon {
    font-size: 1.8rem !important;     /* Antes: 1.3rem */
    width: 40px !important;           /* Antes: 30px */
}

.metric-card .metric-data h3 {
    font-size: 1.3rem !important;     /* Antes: 0.95rem */
    margin-bottom: 2px !important;
}

.metric-card .metric-data p {
    font-size: 0.85rem !important;    /* Antes: 0.7rem */
}


/* ========================================
   GLOBAL FINANCIAL DASHBOARD
   ======================================== */

.financial-filters {
    display: flex;
    gap: 10px;
}

.financial-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.finance-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.finance-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
}

.finance-card.income::after { background: var(--success); }
.finance-card.outcome::after { background: var(--danger); }
.finance-card.profit::after { background: var(--primary); }

.f-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.income .f-card-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.outcome .f-card-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.profit .f-card-icon { background: rgba(129, 0, 0, 0.1); color: var(--primary); }

.f-card-data h3 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.f-card-data p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.finance-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

.breakdown-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.b-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.b-header i {
    font-size: 1.2rem;
    color: var(--primary);
}

.b-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
}

.b-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.b-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.b-item .label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.b-item .value {
    font-weight: 600;
    font-size: 1.05rem;
}

.b-item .value.highlight {
    color: var(--success);
}

.b-item .value.outcome {
    color: var(--danger);
}

.custom-range-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 15px;
    border: 1px solid var(--border);
}

.custom-range-selector input[type="date"] {
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
}
