/* ============================================================
   TutoraX - Global Stylesheet & Design System v2
   Creative, rounded, friendly UI
   ============================================================ */

:root {
    /* Primary brand colors */
    --primary: #6D5DF6;
    --primary-dark: #5B4CE4;
    --primary-light: #A5B4FC;
    --primary-soft: #EEF1FF;

    /* Accent / secondary */
    --accent: #12C39A;
    --accent-dark: #0FA783;
    --accent-soft: #E7FBF5;

    /* Support colors */
    --warning: #FFA726;
    --warning-soft: #FFF8EC;
    --danger: #F4565A;
    --danger-soft: #FFECEC;
    --info: #4C8DF6;
    --info-soft: #EAF2FF;

    /* Neutrals */
    --bg: #F3F5FC;
    --surface: #FFFFFF;
    --surface-2: #F8FAFD;
    --border: #E8ECF5;
    --text: #1B2437;
    --text-muted: #6B7690;
    --text-light: #A3ADc4;

    /* Typography */
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Shadows - soft, rounded */
    --shadow-sm: 0 2px 8px rgba(23,43,99,0.06);
    --shadow: 0 8px 24px rgba(23,43,99,0.08);
    --shadow-lg: 0 20px 50px rgba(23,43,99,0.14);
    --shadow-primary: 0 12px 30px rgba(109,93,246,0.32);

    /* Radius - extra rounded */
    --radius: 20px;
    --radius-lg: 30px;
    --radius-xl: 40px;
    --radius-sm: 14px;
    --pill: 999px;

    /* Transitions */
    --ease: cubic-bezier(0.34, 1.2, 0.64, 1);
    --transition: all 0.3s var(--ease);
}

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

html { scroll-behavior: smooth; }

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

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }

/* -----------------------------------------------
   Typography helpers
   ----------------------------------------------- */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; color: var(--text); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.gradient-text {
    background: linear-gradient(120deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* -----------------------------------------------
   Buttons - rounded
   ----------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 26px;
    border: none;
    border-radius: var(--pill);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7C6CF8);
    color: #fff;
    box-shadow: var(--shadow-primary);
    background-size: 150% 150%;
}
.btn-primary:hover { background-position: 100% 100%; transform: translateY(-3px); color: #fff; box-shadow: 0 16px 36px rgba(109,93,246,0.4); }

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #2DD4BF);
    color: #fff;
    box-shadow: 0 12px 30px rgba(18,195,154,0.32);
    background-size: 150% 150%;
}
.btn-accent:hover { background-position: 100% 100%; transform: translateY(-3px); color: #fff; }

.btn-ghost {
    background: var(--primary-soft);
    color: var(--primary);
}
.btn-ghost:hover { background: #DDE4FF; transform: translateY(-3px); }

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); transform: translateY(-3px); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #F87171);
    color: #fff;
    background-size: 150% 150%;
}
.btn-danger:hover { transform: translateY(-3px); color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: 9px 18px; font-size: 0.84rem; }
.btn-lg { padding: 15px 36px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* Shine animation */
.btn-primary::after, .btn-accent::after, .btn-danger::after {
    content: '';
    position: absolute;
    top: 0; left: -120%;
    width: 60%; height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: btnShine 3.5s infinite;
    transform: skewX(-20deg);
}
@keyframes btnShine {
    0% { left: -120%; }
    55%, 100% { left: 160%; }
}

/* -----------------------------------------------
   Icon buttons
   ----------------------------------------------- */
.icon-btn {
    width: 44px; height: 44px;
    border-radius: var(--pill);
    border: 2px solid var(--border);
    background: var(--surface);
    display: inline-flex;
    align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.icon-btn:hover { background: var(--primary-soft); border-color: var(--primary); transform: translateY(-2px) rotate(-6deg); }

/* -----------------------------------------------
   Forms - rounded
   ----------------------------------------------- */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 5px var(--primary-soft);
}
.form-control::placeholder { color: var(--text-light); }

.input-with-icon { position: relative; }
.input-with-icon .form-control { padding-left: 48px; }
.input-with-icon .password-toggle + .form-control,
.input-with-icon:has(.password-toggle) .form-control,
.input-with-icon .form-control[type="password"] {
    padding-right: 48px;
}
.input-with-icon .input-icon {
    position: absolute;
    left: 16px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.15rem;
    pointer-events: none;
    transition: var(--transition);
}
.input-with-icon:focus-within .input-icon { color: var(--primary); }

/* Locked academy display (shown when joining via a shareable invite link) */
.locked-academy { position: relative; }
.locked-academy .form-control {
    background: var(--surface-2);
    color: var(--text);
    cursor: not-allowed;
    padding-right: 52px;
}
.locked-academy .input-icon { color: var(--primary); }
.lock-badge {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.95rem;
    pointer-events: none;
}


.password-toggle {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 38px; height: 38px;
    border-radius: var(--pill);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.password-toggle svg { transition: transform 0.25s var(--ease); }
.password-toggle:hover { background: var(--primary-soft); color: var(--primary); }
.password-toggle:hover svg { transform: scale(1.1); }
.password-toggle.active { background: var(--primary-soft); color: var(--primary); }

select.form-control { cursor: pointer; appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%236B7690' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center; padding-right: 42px;
}

/* -----------------------------------------------
   Alerts
   ----------------------------------------------- */
.alert {
    padding: 15px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.4s var(--ease);
    border: 1.5px solid transparent;
}
.alert-success { background: var(--accent-soft); color: var(--accent-dark); border-color: #B5ECDd; }
.alert-error { background: var(--danger-soft); color: #C0392B; border-color: #F5C9C9; }
.alert-warning { background: var(--warning-soft); color: #B9770E; border-color: #FCE3B6; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #C7DBFE; }
.alert-icon {
    width: 34px; height: 34px; flex-shrink: 0;
    border-radius: var(--pill);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.alert-success .alert-icon { background: var(--accent); color: #fff; }
.alert-error .alert-icon { background: var(--danger); color: #fff; }
.alert-warning .alert-icon { background: var(--warning); color: #fff; }
.alert-info .alert-icon { background: var(--info); color: #fff; }

/* -----------------------------------------------
   Cards
   ----------------------------------------------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }

/* -----------------------------------------------
   Auth layout
   ----------------------------------------------- */
.auth-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(109,93,246,0.16), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(18,195,154,0.16), transparent 45%),
        radial-gradient(circle at 70% 15%, rgba(255,167,38,0.08), transparent 40%),
        linear-gradient(135deg, #EEF1FF 0%, #F3F5FC 45%, #E7FBF5 100%);
    position: relative;
    overflow: hidden;
}

/* Decorative floating shapes */
.auth-section::before, .auth-section::after,
.auth-blob, .auth-blob2 {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.45;
    animation: blobFloat 14s ease-in-out infinite;
    pointer-events: none;
}
.auth-section::before {
    width: 320px; height: 320px;
    background: var(--primary);
    top: -90px; left: -90px;
    opacity: 0.2;
}
.auth-section::after {
    width: 280px; height: 280px;
    background: var(--accent);
    bottom: -70px; right: -70px;
    opacity: 0.2;
    animation-delay: 5s;
}
.auth-blob, .auth-blob2, .auth-blob3 {
    position: absolute;
    width: 46px; height: 46px;
    border-radius: var(--radius-sm);
    z-index: 1;
    filter: blur(0);
    opacity: 0.5;
    animation: floatY 7s ease-in-out infinite;
}
.auth-blob { background: var(--accent); top: 20%; right: 10%; }
.auth-blob2 { background: var(--warning); bottom: 18%; left: 12%; width: 34px; height: 34px; animation-delay: 2s; border-radius: 50%; }
.auth-blob3 { background: var(--info); top: 12%; left: 18%; width: 28px; height: 28px; animation-delay: 3.5s; border-radius: 50%; }
@keyframes floatY { 0%,100% { transform: translateY(0) rotate(0);} 50% { transform: translateY(-22px) rotate(12deg);} }

@keyframes blobFloat {
    0%,100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(34px,-24px) scale(1.06); }
    66% { transform: translate(-24px,24px) scale(0.94); }
}

.auth-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 580px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.7);
    overflow: hidden;
    animation: fadeInUp 0.7s var(--ease) both;
}

.auth-header {
    padding: 44px 44px 6px;
    text-align: center;
    position: relative;
}

/* Back home button - floating */
.back-home {
    position: absolute;
    top: 22px; left: 22px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--pill);
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    z-index: 5;
}
.back-home:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    transform: translateX(-3px);
}
.back-home .bh-arrow { transition: var(--transition); }

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.brand-logo .logo-icon {
    width: 60px; height: 60px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-primary);
    animation: logoFloat 3.2s ease-in-out infinite;
}
.brand-logo .logo-icon img { width: 100%; height: 100%; object-fit: cover; }
@keyframes logoFloat {
    0%,100% { transform: translateY(0) rotate(0deg); box-shadow: 0 12px 30px rgba(109,93,246,0.32); }
    50% { transform: translateY(-6px) rotate(-2deg); box-shadow: 0 18px 38px rgba(109,93,246,0.4); }
}
.brand-logo .logo-text { font-size: 2rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.brand-logo .logo-text strong { color: var(--primary); }

.auth-header h2 { font-size: 1.7rem; margin-bottom: 6px; }

.auth-body { padding: 22px 44px 44px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 0.95rem; margin-bottom: 26px; }

/* Role selector chips - rounded */
.role-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}
.role-chip {
    padding: 16px 12px;
    border: 2.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}
.role-chip::before {
    content:'';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: var(--transition);
}
.role-chip:hover { border-color: var(--primary-light); transform: translateY(-4px); box-shadow: var(--shadow); }
.role-chip.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--shadow-primary);
}
.role-chip.active::before { transform: scaleX(1); }
.role-chip .role-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    transition: var(--transition);
}
.role-chip.active .role-icon { background: var(--surface); transform: scale(1.08) rotate(-4deg); }
.role-chip .role-name { font-weight: 600; font-size: 0.92rem; }
.role-chip .role-desc { font-size: 0.74rem; color: var(--text-muted); }

.auth-footer { text-align: center; margin-top: 22px; font-size: 0.9rem; color: var(--text-muted); line-height: 1.9; }
span.link { color: var(--primary); font-weight: 600; cursor: pointer; }
span.link:hover { text-decoration: underline; }

.divider {
    display: flex; align-items: center;
    gap: 14px; color: var(--text-light); font-size: 0.8rem;
    margin: 6px 0 20px;
}
.divider::before, .divider::after { content:''; flex: 1; height: 1px; background: var(--border); }

/* -----------------------------------------------
   Animations
   ----------------------------------------------- */
@keyframes fadeInUp { from { opacity:0; transform: translateY(26px);} to { opacity:1; transform: translateY(0);} }
@keyframes fadeIn { from {opacity:0;} to {opacity:1;} }
@keyframes slideDown { from {opacity:0; transform: translateY(-14px);} to {opacity:1; transform: translateY(0);} }
@keyframes spin { 0%{transform:rotate(0);} 100%{transform:rotate(360deg);} }
@keyframes scaleIn { from{opacity:0; transform:scale(0.92);} to{opacity:1; transform:scale(1);} }
@keyframes popIn { 0%{opacity:0; transform:scale(0.6);} 70%{transform:scale(1.08);} 100%{opacity:1; transform:scale(1);} }

.animate-fadeUp { animation: fadeInUp 0.6s var(--ease) both; }
.animate-fade { animation: fadeIn 0.5s ease both; }
.animate-scale { animation: scaleIn 0.4s var(--ease) both; }
    .animate-pop { animation: popIn 0.45s var(--ease) both; }

/* Developer credit */
.dev-credit {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    text-align: center;
    gap: 8px;
    padding: 28px 16px 32px;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    border-top: 1px solid var(--border, #E8ECF5);
    font-size: 0.78rem;
    letter-spacing: 0.4px;
    color: var(--text-light, #8A90A8);
}
.dev-credit strong {
    color: var(--primary, #6D5DF6);
    font-weight: 600;
}
.dev-credit .credit-sep {
    color: var(--border, #E8ECF5);
    font-size: 1rem;
    line-height: 1;
}

/* -----------------------------------------------
   Loader / Spinner - creative
   ----------------------------------------------- */
.loader-overlay {
    position: fixed; inset: 0;
    background: rgba(243,245,252,0.92);
    display: none;
    align-items: center; justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(6px);
}
.loader-overlay.show { display: flex; }
.loader-box { text-align: center; }
.spinner-ring {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--primary), var(--accent), transparent);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
    animation: spin 0.9s linear infinite;
    margin: 0 auto 18px;
}
.spinner {
    width: 50px; height: 50px;
    border: 5px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
.loader-box .loader-text { font-weight: 600; color: var(--primary); }

.btn-spinner {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}
.btn.loading .btn-spinner { display: inline-block; }
.btn.loading .btn-text { opacity: 0.75; }

/* Toast */
.toast-container { position: fixed; top: 22px; right: 22px; z-index: 10000; display: flex; flex-direction: column; gap: 12px; }
.toast {
    min-width: 300px;
    padding: 15px 18px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 12px;
    animation: slideInRight 0.45s var(--ease) both;
    border-left: 5px solid var(--primary);
}
.toast .toast-dot {
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: var(--pill);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
}
.toast.success { border-left-color: var(--accent); }
.toast.success .toast-dot { background: var(--accent); }
.toast.error { border-left-color: var(--danger); }
.toast.error .toast-dot { background: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning .toast-dot { background: var(--warning); }
.toast.hide { animation: slideOutRight 0.4s ease both; }
@keyframes slideInRight { from{opacity:0; transform:translateX(130%);} to{opacity:1; transform:translateX(0);} }
@keyframes slideOutRight { from{opacity:1; transform:translateX(0);} to{opacity:0; transform:translateX(130%);} }

/* -----------------------------------------------
   Responsive
   ----------------------------------------------- */
@media (max-width: 620px) {
    .auth-header, .auth-body { padding-left: 20px; padding-right: 20px; }
    .auth-header { padding-top: 60px; }
    .role-selector { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
    .card { padding: 20px; }
}

/* Tighter mobile layout for very small screens */
@media (max-width: 480px) {
    .auth-section { padding: 12px; }
    .auth-header { padding: 58px 14px 4px; }
    .auth-body { padding: 18px 14px 30px; }
    .auth-header h2 { font-size: 1.4rem; }
    .role-selector { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .role-chip { padding: 12px 8px; }
    .btn-lg { padding: 13px 24px; font-size: 0.98rem; }
    .toast-container { left: 14px; right: 14px; top: 14px; }
    .toast { min-width: 0; width: 100%; }
}
