/* ── Reset & Base ───────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #1a1a2e;
    --color-accent: #e94560;
    --color-bg: #f5f5f5;
    --color-card: #ffffff;
    --color-text: #2d2d2d;
    --color-text-light: #6b7280;
    --color-border: #e5e7eb;
    --color-error: #ef4444;
    --color-success: #10b981;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Login ──────────────────────────────────── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--color-primary), #16213e);
}

.login-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 380px;
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.login-header p {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
}

/* ── Forms ───────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.375rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: var(--font);
    transition: border-color 0.15s;
    background: #fafafa;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: #fff;
}

/* ── Buttons ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--color-accent);
    color: #fff;
}

.btn-primary:hover { background: #d63850; }

.btn-block { width: 100%; }

.btn-logout {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-light);
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
}

.btn-logout:hover { background: #f3f4f6; }

/* ── Cards (Generic) ─────────────────────────── */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
}

.card-header {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--color-primary);
}

.card-body {
    font-size: 0.9375rem;
    color: var(--color-text);
    line-height: 1.5;
}

/* ── Alert ───────────────────────────────────── */
.alert {
    padding: 0.75rem 0.875rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--color-error);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: var(--color-success);
    border: 1px solid #a7f3d0;
}

.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* ── Typography ──────────────────────────────── */
h1, h2, h3, h4 {
    line-height: 1.2;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Navbar ──────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--color-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.125rem;
    font-weight: 700;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-name {
    font-size: 0.8125rem;
    opacity: 0.9;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Dashboard ───────────────────────────────── */
.main-content {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.dashboard-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.dashboard-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.academia-info {
    font-size: 0.875rem;
    color: var(--color-text-light);
}

/* ── Menu Grid (Mobile) ──────────────────────── */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1rem;
    text-decoration: none;
    color: var(--color-text);
    transition: transform 0.1s;
}

.menu-item:active { transform: scale(0.96); }

.menu-icon { font-size: 1.75rem; }

.menu-label {
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ── Responsive ──────────────────────────────── */
/* Mobile-first: base styles are for 320-479px */

@media (min-width: 480px) {
    .login-card { padding: 2.5rem 2rem; }
    .menu-grid { grid-template-columns: 1fr 1fr 1fr; }
    .main-content { padding: 1.25rem; }
    .dashboard-card h2 { font-size: 1.375rem; }
    .schedule-class-name { font-size: 1rem; }
}

@media (min-width: 768px) {
    html { font-size: 17px; }
    .main-content {
        padding: 1.5rem 2rem;
    }
    .menu-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    .menu-item { padding: 1.5rem 1.25rem; }
    .menu-icon { font-size: 2rem; }
    .schedule-card { padding: 1rem 1.25rem; }
    .dashboard-card { padding: 2rem; }
}

@media (min-width: 1024px) {
    .main-content {
        max-width: 800px;
        padding: 2rem;
    }
    .menu-grid { gap: 1.25rem; }
    .dashboard-card h2 { font-size: 1.5rem; }
    .schedule-time { font-size: 1.25rem; }
    .bottom-nav {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
    }
    .toast-container {
        bottom: 80px;
        max-width: 600px;
    }
}

/* ── Schedule ────────────────────────────────── */
.schedule-day-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.day-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    background: var(--color-card);
    color: var(--color-text);
    border: 1.5px solid var(--color-border);
    transition: all 0.15s;
}

.day-chip:active { transform: scale(0.96); }

.day-chip-active {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.day-picker {
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.8125rem;
    font-family: var(--font);
    background: var(--color-card);
    color: var(--color-text);
    flex: 1;
    min-width: 130px;
}

.day-picker:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* ── Schedule Card ──────────────────────────── */
.schedule-card {
    display: flex;
    gap: 0.75rem;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.875rem 1rem;
    margin-bottom: 0.625rem;
    align-items: center;
}

.schedule-card:active { transform: scale(0.99); }

.schedule-time {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-accent);
    min-width: 52px;
    text-align: center;
}

.schedule-info { flex: 1; }

.schedule-class-name {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.schedule-instructor {
    font-size: 0.8125rem;
    color: var(--color-text-light);
    margin-bottom: 0.25rem;
}

.schedule-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-light);
}

/* ── Schedule Empty ─────────────────────────── */
.schedule-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-light);
}

.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }

/* ── Back Button ─────────────────────────────── */
.btn-back {
    display: block;
    text-align: center;
    margin-top: 1rem;
    padding: 0.625rem;
    background: var(--color-card);
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

/* ── Bottom Navigation ───────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--color-primary);
    height: 64px;
    padding: 0 0.5rem;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    text-decoration: none;
    color: rgba(255,255,255,0.65);
    transition: color 0.15s;
    min-height: 44px;
}

.nav-item.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 1.375rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Push main content above bottom nav */
.main-content {
    padding-bottom: 80px;
}

/* ── Toast Notifications ─────────────────────── */
.toast-container {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    max-width: 400px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    cursor: pointer;
}

.toast.toast-hiding {
    animation: toast-out 0.25s ease-in forwards;
}

.toast-success {
    background: #065f46;
    color: #d1fae5;
}

.toast-error {
    background: #991b1b;
    color: #fecaca;
}

.toast-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(16px); }
}

/* ── Skeleton Loader ─────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 65%;
}

.skeleton-card {
    height: 72px;
    margin-bottom: 0.625rem;
    border-radius: var(--radius);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Spinner ─────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-large {
    width: 36px;
    height: 36px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Loading Overlay ─────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.loading-overlay .spinner {
    width: 36px;
    height: 36px;
    border-width: 4px;
}

/* ── Button States ───────────────────────────── */
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

.btn-primary.btn-loading {
    position: relative;
    color: transparent;
}

.btn-primary.btn-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Skeleton Loaders ────────────────────────── */
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.skeleton-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    min-height: 80px;
}

.skeleton-card .skeleton-line {
    height: 14px;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-card .skeleton-line:last-child {
    width: 60%;
    margin-bottom: 0;
}

.skeleton-card .skeleton-title {
    height: 18px;
    width: 70%;
    margin-bottom: 0.75rem;
}

/* Reduce skeleton animation for prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
        background: #e5e7eb;
    }
}

.skeleton-loading .schedule-card {
    pointer-events: none;
    opacity: 0.6;
}

/* ── Error Alert ─────────────────────────────── */
.error-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #991b1b;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.error-alert::before {
    content: "⚠";
    flex-shrink: 0;
    font-size: 1rem;
}

.error-alert.hidden {
    display: none;
}

/* ── Retry Button ────────────────────────────── */
.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    background: transparent;
    color: var(--color-text);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.btn-outline:hover {
    border-color: var(--color-accent);
    background: rgba(233,69,96,0.05);
}

.btn-outline:active {
    transform: scale(0.97);
}

/* ── Toast Container ─────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
    width: calc(100% - 2rem);
}

.toast {
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.7s forwards;
    pointer-events: auto;
}

.toast.toast-error {
    background: var(--color-error);
}

.toast.toast-success {
    background: var(--color-success);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-0.5rem); }
}
