:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: var(--dark-color);
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px;
}

/* Header responsivo */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-menu {
    position: relative;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 20px;
}

.nav-list li a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
    padding: 5px 10px;
    border-radius: 4px;
}

.nav-list li a:hover {
    background-color: rgba(255,255,255,0.1);
}

.dashboard-title {
    margin: 1.5rem 0;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.update-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.last-update {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.update-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.update-btn:hover {
    background-color: #2980b9;
}

.update-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

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

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid var(--secondary-color);
    text-align: center;
}

.stat-card h3 {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-detail {
    font-size: 0.8rem;
    color: #7f8c8d;
}

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

.card {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
}

.top-list {
    list-style: none;
}

.top-list li {
    padding: 0.7rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-list li:last-child {
    border-bottom: none;
}

.rank {
    display: flex;
    align-items: center;
    width: 100%;
}

.rank-number {
    background-color: var(--primary-color);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    margin-right: 8px;
    flex-shrink: 0;
}

.rank-1 .rank-number {
    background-color: gold;
    color: var(--dark-color);
}

.rank-2 .rank-number {
    background-color: silver;
    color: var(--dark-color);
}

.rank-3 .rank-number {
    background-color: #cd7f32;
    color: white;
}

.seminarist-info {
    flex-grow: 1;
    min-width: 0;
}

.seminarist-name {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.seminarist-details {
    font-size: 0.8rem;
    color: #7f8c8d;
}

.seminarist-progress {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}

.progress-value {
    font-weight: 600;
    color: var(--success-color);
    margin-bottom: 5px;
    font-size: 0.8rem;
}

.time-value {
    font-weight: 600;
    color: var(--info-color);
    margin-bottom: 5px;
    font-size: 0.8rem;
}

.progress-bar {
    height: 6px;
    width: 80px;
    background-color: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--success-color);
}

.branches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.branch-card {
    background-color: var(--light-color);
    padding: 1rem;
    border-radius: 8px;
    border-top: 4px solid var(--secondary-color);
}

.branch-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.8rem;
    font-size: 1rem;
}

.branch-top-list {
    list-style: none;
}

.branch-top-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
}

.branch-top-list li:last-child {
    border-bottom: none;
}

.branch-rank {
    display: flex;
    align-items: center;
    width: 100%;
}

.branch-rank-number {
    background-color: var(--primary-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
    margin-right: 6px;
    flex-shrink: 0;
}

.branch-rank-1 .branch-rank-number {
    background-color: gold;
    color: var(--dark-color);
}

.branch-rank-2 .branch-rank-number {
    background-color: silver;
    color: var(--dark-color);
}

.branch-rank-3 .branch-rank-number {
    background-color: #cd7f32;
    color: white;
}

.branch-seminarist-info {
    flex-grow: 1;
    min-width: 0;
}

.branch-seminarist-name {
    font-weight: 600;
    font-size: 0.8rem;
}

.branch-seminarist-details {
    font-size: 0.7rem;
    color: #7f8c8d;
}

.branch-progress-value {
    font-weight: 600;
    color: var(--success-color);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.scripture-list {
    list-style: none;
}

.scripture-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scripture-list li:last-child {
    border-bottom: none;
}

.scripture-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.scripture-count {
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.8rem;
    text-align: right;
}

.learning-status {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.status-label {
    font-weight: 600;
    font-size: 0.9rem;
}

.status-value {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.overall-progress {
    margin-top: 8px;
}

.progress-bar-large {
    height: 16px;
    background-color: #eee;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-fill-large {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--success-color));
    border-radius: 8px;
}

.chart-container {
    height: 180px;
    margin-top: 1rem;
    position: relative;
}

.chart-bar {
    display: flex;
    align-items: flex-end;
    height: 100%;
    gap: 8px;
}

.chart-item {
    flex: 1;
    background-color: var(--secondary-color);
    border-radius: 4px 4px 0 0;
    position: relative;
}

.chart-label {
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    color: #7f8c8d;
}

.chart-value {
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.7rem;
}

/* ESTILOS MEJORADOS PARA LA TABLA EN MÓVIL */
.table-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 8px 35px 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c8d;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 0.9rem;
    min-width: 150px;
}

.table-scroll-container {
    position: relative;
    overflow-x: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: white;
    -webkit-overflow-scrolling: touch;
}

.scroll-indicator {
    display: none;
    text-align: center;
    padding: 8px;
    background: linear-gradient(90deg, transparent, #f8f9fa, transparent);
    color: #7f8c8d;
    font-size: 0.8rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

table th, table td {
    padding: 0.7rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
}

table th {
    background-color: var(--light-color);
    color: var(--primary-color);
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

table th[data-priority="1"],
table th[data-priority="2"] {
    background-color: #e3f2fd;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-completed {
    background-color: #e8f6f3;
    color: var(--success-color);
}

.status-inprogress {
    background-color: #fef9e7;
    color: var(--warning-color);
}

.table-info {
    margin-top: 10px;
    text-align: center;
    color: #7f8c8d;
    font-size: 0.8rem;
}

footer {
    background-color: var(--dark-color);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

.icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 6px;
    text-align: center;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s, transform 0.3s;
    font-size: 0.9rem;
    max-width: 300px;
}

.notification.success {
    background-color: var(--success-color);
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background-color: var(--accent-color);
    opacity: 1;
    transform: translateY(0);
}

.connection-status {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.connection-status.connected {
    background-color: #e8f6f3;
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.connection-status.error {
    background-color: #fdeaea;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.metric-explanation {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 5px;
    font-style: italic;
}

/* MEDIA QUERIES PARA MÓVIL */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .nav-toggle {
        display: block;
        position: absolute;
        right: 0;
        top: -5px;
    }
    
    .nav-list {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--primary-color);
        padding: 10px;
        border-radius: 4px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 1000;
        min-width: 150px;
    }
    
    .nav-list.show {
        display: flex;
    }
    
    .dashboard-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .update-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card {
        padding: 1rem;
    }
    
    .card h2 {
        font-size: 1rem;
    }
    
    .progress-bar {
        width: 60px;
    }
    
    .branches-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 150px;
    }
    
    .table-controls {
        flex-direction: column;
    }
    
    .search-box,
    .filter-select {
        min-width: 100%;
    }
    
    .scroll-indicator {
        display: block;
    }
    
    table th,
    table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Ocultar columnas menos importantes en móvil */
    table th[data-priority="5"],
    table th[data-priority="6"],
    table td:nth-child(5),
    table td:nth-child(6) {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .stat-card h3 {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .progress-bar {
        width: 50px;
    }
    
    /* Ocultar más columnas en pantallas muy pequeñas */
    table th[data-priority="4"],
    table td:nth-child(4) {
        display: none;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    table th[data-priority="6"],
    table td:nth-child(6) {
        display: none;
    }
}