/* 
 * Clinikora - Módulo Estadísticas
 * Diseño premium con dashboard de KPIs y lista de informes.
 */

:root {
    --stat-red: #ff5252;
    --stat-green: #4caf50;
    --stat-orange: #ff9800;
    --stat-blue: #2196f3;
}

.stats-page {
    display: flex;
    gap: 32px;
    padding: 24px;
    height: 100%;
    background: #f8f9fa;
    overflow-y: auto;
}

/* Panel Izquierdo: Lista de Informes */
.stats-left-panel {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--gray-d);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--ink);
}

.stats-category-item:hover {
    border-color: var(--blue);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stats-category-item .icon-info {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    border-radius: 50%;
    font-size: 11px;
    color: var(--ink-l);
    font-weight: 700;
}

.stats-category-item span {
    font-size: 13.5px;
    font-weight: 500;
}

.stats-category-item::before {
    content: "·";
    font-size: 20px;
    color: var(--ink-l);
}

/* Panel Derecho: Dashboard de KPIs */
.stats-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.stat-card {
    position: relative;
    padding: 24px;
    border-radius: 16px;
    color: white;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card::after {
    content: "";
    position: absolute;
    top: -20%;
    right: -10%;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.stat-card.red {
    background: linear-gradient(135deg, #ff7675, #d63031);
}

.stat-card.green {
    background: linear-gradient(135deg, #55efc4, #00b894);
}

.stat-card.orange {
    background: linear-gradient(135deg, #fab1a0, #e17055);
}

.stat-card.blue {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
}

.stat-card.purple {
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
}

.stat-card.cyan {
    background: linear-gradient(135deg, #00cec9, #00aba9);
}

.stat-card.darkred {
    background: linear-gradient(135deg, #c0392b, #962d22);
}

.stat-card-val {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1;
}

.stat-card-label {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-icon {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 32px;
    opacity: 0.3;
}

.advanced-stats-row {
    margin-top: 30px;
}

.chart-container-fixed {
    height: 280px;
    position: relative;
}

.chart-container-small {
    height: 200px;
    position: relative;
}

/* Header Slot */
.stats-hdr {
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 100%;
}

.stats-hdr h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

/* Detalle de Informes */
.stats-detail-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: #fff;
    border-bottom: 1px solid var(--gray-d);
}

.stats-detail-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
}

.stats-detail-btns {
    display: flex;
    gap: 12px;
}

.stats-detail-page {
    padding: 12px;
    background: #f1f3f6;
    overflow-y: auto;
    flex: 1;
}

.stats-filters-card {
    background: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 14px;
    border: 1px solid #eee;
}

/* Selector Rápido de Fechas */
.stats-date-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--gray-d);
}

.date-quick-tabs {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    justify-content: space-between;
}

.year-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: var(--blue);
}

.year-nav button {
    background: none;
    border: none;
    color: var(--blue);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
}

.tabs-group {
    display: flex;
    background: #f0f2f5;
    padding: 4px;
    border-radius: 8px;
}

.tab-btn {
    padding: 4px 10px;
    border: none;
    background: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-l);
    cursor: pointer;
    border-radius: 6px;
}

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

.months-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
    flex: 1;
    margin-left: 20px;
}

.months-grid button {
    padding: 3px 2px;
    border: 1px solid transparent;
    background: none;
    color: var(--blue);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
}

.months-grid button:hover {
    background: #e3f2fd;
    border-color: #bbdefb;
}

/* Rejilla de Filtros */
.stats-filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.filter-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.filter-row label {
    flex: 0 0 120px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}

.filter-row input,
.filter-row select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--gray-d);
    border-radius: 8px;
    font-size: 13px;
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.stats-show-btn-wrap {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.btn-show-stats {
    background: #4caf50 !important;
    color: #fff !important;
    padding: 10px 32px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-show-stats:hover {
    background: #43a047 !important;
    transform: scale(1.05);
}

/* Resultados */
.stats-results-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.stats-results-header {
    padding: 12px 24px;
    background: #fcfcfd;
    border-bottom: 1px solid var(--gray-d);
}

.btn-excel {
    background: #2196f3 !important;
    color: #fff !important;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.stats-table-wrapper {
    max-height: 600px;
    overflow: auto;
    background: #fff;
}

.clinic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.clinic-table th {
    background: #f8f9fa;
    color: var(--ink-l);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 14px 12px;
    border-bottom: 2px solid var(--gray-d);
    text-align: left;
    white-space: nowrap;
}

.clinic-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--gray-d);
    color: var(--ink);
    vertical-align: middle;
}

.clinic-table tr:hover {
    background-color: #fcfcfd;
}

.stats-error {
    padding: 40px;
    text-align: center;
    color: var(--stat-red);
    font-weight: 600;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    color: white;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    min-width: 80px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-orange {
    background: #e67e22 !important;
    color: #fff !important;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-orange:hover {
    background: #cf6d17 !important;
}

.btn-blue {
    background: var(--blue) !important;
    color: #fff !important;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-blue:hover {
    background: var(--blue-h) !important;
}

/* Tratamientos Stats: Rangos y Chips */
.ranges-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.range-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #00bcd4;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.range-chip .btn-remove-range {
    background: none;
    border: none;
    color: white;
    font-weight: 900;
    cursor: pointer;
    padding: 0 2px;
    font-size: 16px;
    display: flex;
    align-items: center;
    line-height: 1;
}

.range-chip .btn-remove-range:hover {
    color: #ff5252;
}

.btn-add-range {
    background: none;
    border: none;
    color: #4caf50;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    padding: 0;
}

.btn-add-range:hover {
    transform: scale(1.15);
}

/* Tablas comparativas */
.clinic-table.table-comparative th {
    text-align: center;
}

.clinic-table.table-comparative th.th-left {
    text-align: left;
}