:root {
    --bg: #0c0c14;
    --bg-gradient: radial-gradient(1200px 600px at 20% -10%, rgba(30, 95, 168, 0.18), transparent 60%),
                   radial-gradient(1000px 500px at 100% 0%, rgba(74, 139, 216, 0.12), transparent 55%),
                   linear-gradient(180deg, #0c0c14 0%, #0f0f1a 100%);
    --surface: rgba(255, 255, 255, 0.03);
    --surface-solid: #16161f;
    --surface-2: rgba(255, 255, 255, 0.06);
    --surface-3: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text: #ececf4;
    --text-dim: #9a9ab0;
    --text-faint: #6b6b85;

    --primary: #2557a7;
    --primary-hover: #2e63b6;
    --primary-rgb: 37, 87, 167;
    --primary-grad: linear-gradient(135deg, #2557a7 0%, #3e7bc4 100%);
    --accent: #4a8bd8;

    --success: #2f9e63;
    --warning: #fbbf24;
    --error: #f87171;
    --info: #60a5fa;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Sora', 'Inter', -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;

    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);

    --glow: 0 0 0 1px rgba(37, 87, 167, 0.25), 0 8px 30px -10px rgba(37, 87, 167, 0.4);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --header-h: 82px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

::selection {
    background: rgba(var(--primary-rgb), 0.35);
    color: #fff;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 20px;
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-rgb), 0.5);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* --- Header --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(12, 12, 20, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
}

.logo-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--glow);
}

.logo-text h1 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    background: linear-gradient(135deg, #fff 0%, #c8bfff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.logo-text p {
    font-size: 0.78rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-back-header {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--transition);
}

.btn-back-header:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
}

/* --- Main --- */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.2rem 1.25rem 4rem;
}

.view {
    display: none;
}
[hidden] {
    display: none !important;
}
.view.active {
    display: block;
    animation: fadeUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.page-sub {
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* --- Grid de tutores --- */
.tutores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.tutor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem 1.6rem;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.tutor-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--glow);
}

.tutor-card-accent {
    width: 42px;
    height: 6px;
    border-radius: 4px;
    background: var(--primary-grad);
}

.tutor-card h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tutor-card p {
    color: var(--text-dim);
    font-size: 0.9rem;
    flex: 1;
}

.tutor-card-meta {
    font-size: 0.78rem;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* --- Detalle del tutor --- */
.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-accent {
    width: 6px;
    height: 52px;
    border-radius: 4px;
    background: var(--primary-grad);
    flex-shrink: 0;
}

.detail-title {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.detail-desc {
    color: var(--text-dim);
    margin-bottom: 1.75rem;
    font-size: 0.98rem;
    max-width: 760px;
}

.bloques-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.bloque {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.bloque-header {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1.1rem 1.4rem;
    cursor: pointer;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
}

.bloque-id {
    background: var(--primary-grad);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--glow);
}

.bloque-title {
    font-weight: 600;
    font-size: 1.05rem;
    font-family: var(--font-display);
    letter-spacing: -0.01em;
    flex: 1;
}

.bloque-chevron {
    color: var(--text-faint);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.bloque.open .bloque-chevron {
    transform: rotate(180deg);
}

.bloque-body {
    padding: 1.25rem 1.4rem;
}

.bloque-objetivos h4 {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.6rem;
}

.bloque-objetivos ul {
    margin-left: 1.4rem;
    margin-bottom: 1.1rem;
}

.bloque-objetivos li {
    margin-bottom: 0.4rem;
    font-size: 0.92rem;
}

.prompt-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    margin-bottom: 1rem;
    max-height: 260px;
    overflow-y: auto;
}

.bloque-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

/* --- Botones --- */
.btn {
    padding: 0.62rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    letter-spacing: 0.01em;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn.primary {
    background: var(--primary-grad);
    color: #fff;
    box-shadow: 0 8px 20px -8px rgba(37, 87, 167, 0.6);
}

.btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #2e63b6 0%, #4a8bd8 100%);
    box-shadow: 0 12px 28px -8px rgba(37, 87, 167, 0.75);
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--border-strong);
}

/* --- Dropdown --- */
.dropdown {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.dropdown-trigger {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    background: var(--primary-grad);
    color: #fff;
    border: none;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    box-shadow: 8px 8px 20px -8px rgba(37, 87, 167, 0.6);
}

.dropdown-toggle:hover {
    background: linear-gradient(135deg, #2e63b6 0%, #4a8bd8 100%);
}

.dropdown.open .dropdown-toggle svg {
    transform: rotate(180deg);
}

.dropdown-toggle svg {
    transition: transform var(--transition);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
    z-index: 50;
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover {
    background: rgba(var(--primary-rgb), 0.12);
    color: #fff;
}

/* --- Estados vacíos --- */
.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-xl);
    color: var(--text-dim);
}

.empty-state h2 {
    font-family: var(--font-display);
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* --- Toasts --- */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(360px, calc(100vw - 2.5rem));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    color: var(--text);
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.toast.hide {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

.toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: var(--info);
}

.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--error); }
.toast.warning::before { background: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.4;
}

/* --- Idioma (header) --- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.lang-switch {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.2rem;
    gap: 0.2rem;
}

.lang-btn {
    appearance: none;
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-radius: 7px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: var(--font);
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all var(--transition);
}

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

.lang-btn.active {
    background: var(--primary-grad);
    color: #fff;
    box-shadow: 0 4px 12px -4px rgba(37, 87, 167, 0.6);
}

/* --- Botón flotante de sugerencias --- */
.btn-suggest {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    background: var(--primary-grad);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg), 0 8px 24px -8px rgba(37, 87, 167, 0.7);
    transition: all var(--transition);
}

.btn-suggest:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 44px -12px rgba(37, 87, 167, 0.85);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(8, 8, 14, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    width: min(560px, 100%);
    max-height: min(85vh, 640px);
    overflow-y: auto;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem;
    animation: modalPop 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes modalPop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.modal-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
}

/* --- Formularios (modal público) --- */
.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.field select,
.field textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 0.7rem 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.field textarea {
    resize: vertical;
    min-height: 110px;
    line-height: 1.55;
}

.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--glow);
}

.field select option {
    background: var(--surface-solid);
    color: var(--text);
}

.field-hint {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-top: 0.3rem;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    main {
        padding: 1.4rem 0.9rem 3rem;
    }

    .tutores-grid {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.45rem;
    }

    .detail-title {
        font-size: 1.35rem;
    }

    .bloque-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .bloque-actions .btn,
    .bloque-actions .dropdown {
        width: 100%;
    }

    .bloque-actions .dropdown-trigger {
        flex: 1;
    }

    .bloque-actions .dropdown-menu {
        left: 0;
        right: auto;
        width: 100%;
        min-width: 0;
    }

    .logo-text h1 {
        font-size: 1.15rem;
    }

    .logo-text p {
        white-space: normal;
    }

    .header-actions {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .btn-suggest {
        bottom: 1rem;
        right: 1rem;
        padding: 0.65rem 0.9rem;
    }

    .btn-suggest span {
        display: none;
    }

    .modal {
        padding: 1.25rem;
    }
}
