:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --glass-border: rgba(255, 255, 255, 0.3);
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.9);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --glass-border: rgba(255, 255, 255, 0.05);
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-main);
    line-height: 1.5;
    padding: 2rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Glassmorphism Card Style */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out;
}

/* Filters Layout */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 0.95rem;
    background-color: var(--bg-color);
    color: var(--text-main);
    transition: all 0.2s;
}

select {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid #d1d5db;
    background: white;
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-btn {
    background: var(--primary-color);
    color: white;
    padding: 0.85rem 2rem;
    border: none;
    border-radius: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.search-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.search-btn:active {
    transform: scale(0.98);
}

.clear-btn {
    background: var(--bg-color);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 3rem;
    align-self: flex-end;
}

.clear-btn:hover {
    background: #e5e7eb;
}

.clear-btn:active {
    transform: scale(0.98);
}

/* Table Design */
.table-container {
    overflow-x: auto;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th {
    padding: 1.25rem 1.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 1.25rem 1.5rem;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

/* Proportional column widths */
td[data-label="Asignatura/Programa"] {
    min-width: 350px;
    white-space: normal;
}

td[data-label="Docente"] {
    min-width: 300px;
    white-space: nowrap;
    /* Keep name in one line */
}

/* On desktop, allow a bit more room for the name */
@media (min-width: 1024px) {
    td[data-label="Docente"] {
        min-width: 350px;
    }
}

tr:hover {
    background: rgba(79, 70, 229, 0.05);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-blue {
    background: #eff6ff;
    color: #1e40af;
}

.badge-green {
    background: #ecfdf5;
    color: #065f46;
}

.badge-purple {
    background: #f5f3ff;
    color: #5b21b6;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.page-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn:not(:disabled):hover {
    background: #f3f4f6;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.75rem;
    }

    /* Forcing table to not be a table anymore */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid var(--border-color);
        margin-bottom: 1.5rem;
        background: white;
        border-radius: 1rem;
        overflow: hidden;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }

    td {
        border: none;
        border-bottom: 1px solid #f3f4f6;
        padding: 0.75rem 1rem;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        text-align: right;
        gap: 0.25rem;
    }

    td[data-label="Docente"],
    td[data-label="Asignatura"] {
        white-space: normal !important;
        min-width: 0 !important;
        max-width: 100%;
        word-break: break-word;
    }

    td:before {
        position: static;
        width: 100%;
        margin-bottom: 0.25rem;
        content: attr(data-label);
        font-weight: 700;
        text-align: left;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    td>* {
        max-width: 100%;
    }

    td:last-child {
        border-bottom: none;
    }
}

/* Loading Spinner */
.loader-container {
    display: none;
    justify-content: center;
    padding: 2rem;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.badge-live {
    background: #ef4444;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    animation: pulse 2s infinite;
    margin-left: 0.5rem;
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.view-btn {
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}

.view-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.view-btn:hover:not(.active) {
    background: var(--border-color);
}

/* Tooltip Styles */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 220px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text-main);
    text-align: left;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 0;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.6;
    pointer-events: none;
    transform: translateY(10px);
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.15rem;
}

.tooltip-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tooltip-label {
    color: var(--text-muted);
}

.tooltip-value {
    font-weight: 600;
    color: var(--primary-color);
}