@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap');

:root {
    --bg-grad-1: #eef2ff;
    --bg-grad-2: #f7f0ff;
    --primary-500: #667eea;
    --primary-600: #5a67d8;
    --accent-600: #764ba2;
    --muted: #6b7280;
    --surface: #ffffff;
    --glass: rgba(255,255,255,0.6);
    --success: #28a745;
    --danger: #dc3545;
    --shadow-lg: 0 20px 60px rgba(15,23,42,0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    background: linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
    min-height: 100vh;
    padding: 28px;
    color: #111827;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.98));
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

header {
    background: transparent;
    color: var(--primary-600);
    padding: 26px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.6rem;
    margin-bottom: 4px;
    color: #0f172a;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    padding: 20px;
}

.auth-container {
    max-width: 520px;
    margin: 40px auto;
    background: var(--surface);
    padding: 28px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(2,6,23,0.08);
}

.auth-container h2 {
    margin-bottom: 12px;
    color: #0f172a;
}

.auth-container form {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.auth-container input[type="email"],
.auth-container input[type="password"],
.form-control {
    padding: 12px 14px;
    border: 1px solid #e6e9ef;
    border-radius: 10px;
    background: #fff;
    transition: box-shadow .15s, transform .08s;
}

.auth-container input:focus, .form-control:focus {
    outline: none;
    box-shadow: 0 6px 18px rgba(102,126,234,0.12);
    transform: translateY(-1px);
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: calc(100vh + 80px);
    overflow: hidden;
}

/* Panel de búsqueda */
.search-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.search-panel h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(90deg, var(--primary-500), var(--accent-600));
    color: white;
    padding: 10px 18px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(102,126,234,0.12);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(102,126,234,0.18);
}

.btn-secondary {
    background: #111827;
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
}

.btn-outline {
    background: transparent;
    border: 1px solid #e6e9ef;
    color: #0f172a;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 20px;
    color: #667eea;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Materias container */
.materias-container {
    background: rgb(255, 255, 255);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
    overflow: hidden;
}

.materias-header{
    margin-bottom: 15px;
}

.materias-list {
    height: calc(100vh - 450px);
    overflow-y: auto;
    padding-right: 5px;

    border-top: 1px solid #eee;
    padding-top: 10px;

}

.materias-container h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.search-box {
    margin-bottom: 15px;
}

.materia-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-500);
    cursor: pointer;
    transition: all 0.3s;
}

.materia-item:hover {
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.materia-item.agregada {
    opacity: 0.6;
    border-left-color: #28a745;
}

.materia-nombre {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.materia-info {
    font-size: 12px;
    color: #666;
    margin: 3px 0;
}

.materia-horario {
    font-size: 12px;
    color: #667eea;
    font-weight: 500;
    margin-top: 8px;
}

/* Calendario */
.calendar-panel {
    background: linear-gradient(180deg, #fbfdff, #f6f8ff);
    padding: 22px;
    border-radius: 12px;
}

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

.calendar-header h2 {
    color: #667eea;
    font-size: 1.5em;
}

.calendar-grid {
    display: grid;
    grid-template-columns: 80px repeat(6, 1fr);
    gap: 1px;
    background: #ddd;
    border: 1px solid #ddd;
}

.calendar-cell {
    background: white;
    padding: 0;
    height: 60px;
    position: relative;
}

.calendar-cell.header {
    background: linear-gradient(90deg, var(--primary-500), var(--accent-600));
    color: white;
    font-weight: 700;
    text-align: center;
    padding: 12px 8px;
}

.calendar-cell.time {
    font-weight: 600;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    font-size: 12px;
}

.clase-block {
    position: absolute;
    left: 1px;
    right: 1px;
    top: 0;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: filter 0.3s, z-index 0.3s;
    color: white;
    z-index: 1;
}

.pro-badge {
    display: inline-block;
    background: linear-gradient(90deg, #ffb86b, #ff7a59);
    color: #0f172a;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
}

.clase-block:hover {
    filter: brightness(1.1);
    z-index: 10;
}

.clase-nombre {
    font-weight: 600;
    margin-bottom: 3px;
}

.clase-info {
    font-size: 10px;
    opacity: 0.9;
}

.clase-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 18px;
    padding: 0;
    display: none;
}

.clase-block:hover .clase-remove {
    display: block;
}

/* Leyenda */
.legend {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

/* Ad banner */
.ad-banner {
    background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(255,255,255,0.95));
    border: 1px dashed #e6e9ef;
    padding: 12px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    background: #fbfbff;
    border-radius: 8px;
    padding: 10px 12px;
}

/* Toast */
.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    background: rgba(15,23,42,0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(2,6,23,0.24);
    z-index: 1200;
}

.legend h4 {
    color: #333;
    margin-bottom: 10px;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 5px;
    position: relative;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
}

.legend-text {
    font-size: 13px;
    color: #333;
    flex: 1;
}

.legend-remove {
    background: #dc3545;
    border: none;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 18px;
    padding: 0;
    transition: all 0.3s;
}

.legend-remove:hover {
    background: #c82333;
    transform: scale(1.1);
}

.empty-message {
    color: #999;
    font-style: italic;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Modal de conflicto */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay.modal-closing {
    animation: fadeOut 0.2s ease forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-error .modal-header {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: white;
    padding: 20px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    font-size: 1.8em;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin-bottom: 15px;
    color: #333;
    line-height: 1.5;
}

.conflicto-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
}

.conflicto-materia {
    border-left: 4px solid;
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.conflicto-materia strong {
    color: #333;
    font-size: 1em;
}

.conflicto-materia span {
    color: #666;
    font-size: 0.9em;
}

.modal-hint {
    font-size: 0.9em;
    color: #888 !important;
    font-style: italic;
    margin-top: 10px;
}

.modal-actions {
    padding: 15px 25px 25px;
    display: flex;
    justify-content: center;
}

.btn-modal-close {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 35px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-modal-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .left-panel {
        height: auto;
        max-height: none;
        overflow: visible;
    }
    
    .calendar-grid {
        grid-template-columns: 60px repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 10px;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    .main-content {
        padding: 10px;
        gap: 15px;
    }
    
    .left-panel {
        padding: 10px;
        gap: 15px;
    }
    
    .search-panel {
        padding: 15px;
    }
    
    .search-panel h2 {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-control {
        padding: 8px;
        font-size: 14px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .materias-container {
        padding: 15px;
    }
    
    .materias-container h3 {
        font-size: 1.1em;
    }
    
    .materia-item {
        padding: 12px;
    }
    
    .materia-nombre {
        font-size: 14px;
    }
    
    .materia-info {
        font-size: 11px;
    }
    
    .calendar-panel {
        padding: 15px;
    }
    
    .calendar-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .calendar-header h2 {
        font-size: 1.2em;
    }
    
    .calendar-grid {
        grid-template-columns: 45px repeat(6, 1fr);
        font-size: 9px;
    }
    
    .calendar-cell {
        height: 50px;
    }
    
    .calendar-cell.header {
        padding: 8px 2px;
        font-size: 10px;
    }
    
    .calendar-cell.time {
        font-size: 9px;
    }
    
    .clase-block {
        padding: 2px 3px;
        font-size: 8px;
    }
    
    .clase-nombre {
        font-size: 8px;
        margin-bottom: 1px;
    }
    
    .clase-info {
        font-size: 7px;
    }
    
    .clase-remove {
        width: 14px;
        height: 14px;
        font-size: 10px;
        top: 2px;
        right: 2px;
    }
    
    .legend {
        padding: 10px;
    }
    
    .legend h4 {
        font-size: 13px;
    }
    
    .legend-items {
        gap: 8px;
    }
    
    .legend-item {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .legend-color {
        width: 16px;
        height: 16px;
    }
    
    .legend-text {
        font-size: 11px;
    }
    
    .legend-remove {
        width: 16px;
        height: 16px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.2em;
    }
    
    .calendar-grid {
        grid-template-columns: 35px repeat(6, 1fr);
    }
    
    .calendar-cell.header {
        font-size: 8px;
        padding: 6px 1px;
    }
    
    .calendar-cell.time {
        font-size: 8px;
    }
    
    .calendar-cell {
        height: 45px;
    }
    
    .clase-block {
        padding: 1px 2px;
        font-size: 7px;
    }
    
    .btn-secondary {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Alerts */
.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}


/* Schedule Blocks */
.clase-block {
    position: absolute;
    width: calc(100% - 4px);
    left: 2px;
    z-index: 20;
    color: white;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.1s, box-shadow 0.1s;
}

.clase-block:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 30;
}

.clase-title {
    font-weight: 700;
    font-size: 10px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.clase-info {
    font-size: 9px;
    opacity: 0.9;
}

