/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #1e293b; background: #f8fafc; line-height: 1.6; min-height: 100vh; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* === Navbar === */
.navbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: white; border-bottom: 2px solid #e2e8f0; position: sticky; top: 0; z-index: 100; flex-wrap: wrap; gap: 8px; }
.nav-brand a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #1e293b; }
.brand-icon { font-size: 1.5rem; }
.brand-icon-img { width: 28px; height: 28px; }
.brand-text { font-size: 1.25rem; font-weight: 700; }
.brand-sub { font-size: 0.75rem; color: #64748b; margin-left: 8px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a { padding: 6px 14px; border-radius: 8px; color: #475569; font-weight: 500; font-size: 0.9rem; transition: all 0.15s; }
.nav-links a:hover, .nav-links a.active { background: #eff6ff; color: #2563eb; text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 12px; }

/* === Buttons === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 0.875rem; border: none; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-accent { background: #10b981; color: white; }
.btn-accent:hover { background: #059669; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1px solid #cbd5e1; color: #475569; }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* === Cards === */
.card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 16px; }
.card h3 { margin-bottom: 12px; font-size: 1.1rem; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.875rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
select, textarea { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.9rem; width: 100%; font-family: inherit; transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-row select { width: auto; }
.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input-flex { flex: 1; min-width: 200px; }
.input-md { width: 200px; }
.input-full { width: 100%; }
.input-search { max-width: 300px; }
.inline-form { display: inline; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; cursor: pointer; white-space: nowrap; }

/* === Tables === */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.data-table th { background: #f1f5f9; padding: 10px 14px; text-align: left; font-size: 0.8rem; text-transform: uppercase; color: #64748b; font-weight: 600; }
.data-table td { padding: 10px 14px; border-top: 1px solid #f1f5f9; font-size: 0.9rem; }
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: #f8fafc; }
.row-past { opacity: 0.6; }
.row-done { background: #f0fdf4; }
.row-cancelled { background: #fef2f2; text-decoration: line-through; }
.row-danger { background: #fef2f2; }
.col-date { white-space: nowrap; }
.col-topic { max-width: 400px; }

/* === Status & Category Badges === */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.status-upcoming { background: #dbeafe; color: #1e40af; }
.status-done { background: #dcfce7; color: #166534; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-accepted { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.category-tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.cat-HPB { background: #dbeafe; color: #1e40af; }
.cat-OLT { background: #dcfce7; color: #166534; }
.cat-Pancreatic { background: #fef3c7; color: #92400e; }
.cat-Journal-Club { background: #f3e8ff; color: #6b21a8; }

/* === User Badge === */
.user-badge { padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }
.role-coordinator { background: #dbeafe; color: #1e40af; }
.role-trainee { background: #dcfce7; color: #166534; }
.role-guest { background: #f3e8ff; color: #6b21a8; }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 0.75rem; }
.role-external { background: #fef3c7; color: #92400e; }
.role-consultant { background: #e0e7ff; color: #3730a3; }

/* === Page Header === */
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.view-toggle { display: flex; gap: 2px; }

/* === Login === */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card { background: white; border-radius: 16px; padding: 40px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 24px; }
.login-header h1 { font-size: 1.75rem; color: #1e293b; }
.login-subtitle { color: #64748b; font-size: 0.9rem; margin-top: 4px; }
.login-form .form-group { margin-bottom: 16px; }
.login-footer { text-align: center; margin-top: 16px; font-size: 0.8rem; color: #94a3b8; }

/* === Filters === */
.filters-bar { margin-bottom: 24px; }
.filters-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters-form select { width: auto; }

/* === Calendar View === */
.calendar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.calendar-slot { background: white; border-radius: 12px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); transition: all 0.15s; text-decoration: none; color: inherit; border-left: 4px solid #2563eb; }
.calendar-slot:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); text-decoration: none; }
.calendar-slot.slot-past { opacity: 0.5; border-left-color: #94a3b8; }
.calendar-slot.slot-done { border-left-color: #10b981; }
.calendar-slot.slot-cancelled { border-left-color: #ef4444; }
.slot-date { font-weight: 700; font-size: 0.95rem; }
.slot-day { font-size: 0.8rem; color: #64748b; }
.slot-topic { font-size: 0.85rem; margin-top: 8px; }
.slot-empty { color: #94a3b8; font-style: italic; }
.slot-speaker { font-size: 0.8rem; color: #64748b; margin-top: 4px; }
.calendar-break { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; text-align: center; padding: 20px; border-radius: 12px; font-weight: 700; font-size: 1.1rem; grid-column: 1 / -1; }

/* === Break Row === */
.break-row td { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; font-weight: 700; text-align: center; font-size: 1rem; }
.break-cell { padding: 12px !important; }

/* === Session Detail === */
.session-grid { display: grid; grid-template-columns: 1fr 350px; gap: 24px; }
.session-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.meta-item { font-size: 0.9rem; }
.admin-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.action-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.whatsapp-preview { margin-top: 12px; padding: 12px; background: #f0fdf4; border-radius: 8px; }

/* === Rating === */
.rating { color: #f59e0b; }
.star-filled { color: #f59e0b; }
.star-empty { color: #e2e8f0; }
.star-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.star-rating input { display: none; }
.star-rating label { cursor: pointer; font-size: 1.5rem; color: #e2e8f0; transition: color 0.1s; }
.star-rating input:checked ~ label, .star-rating label:hover, .star-rating label:hover ~ label { color: #f59e0b; }
.rating-input { margin-bottom: 12px; }
.rating-stars { color: #f59e0b; }

/* === Feedback === */
.feedback-form { margin-bottom: 24px; }
.feedback-list { margin-top: 16px; }
.feedback-item { padding: 12px; border-bottom: 1px solid #f1f5f9; }
.feedback-item:last-child { border-bottom: none; }
.feedback-rating { margin-bottom: 4px; }
.feedback-comment { font-size: 0.9rem; margin: 4px 0; }
.feedback-meta { color: #94a3b8; }

/* === Uploads === */
.upload-list { list-style: none; }
.upload-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap; }
.upload-link { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.file-icon { font-size: 1.2rem; }
.upload-meta { font-size: 0.8rem; color: #94a3b8; }
.upload-form { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* === Suggestion Box === */
.suggestion-box { margin-top: 32px; background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.suggestion-form .form-row { gap: 8px; }

/* === Stats === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 20px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.stat-value { font-size: 2rem; font-weight: 700; color: #2563eb; }
.stat-label { font-size: 0.85rem; color: #64748b; margin-top: 4px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* === Coverage === */
.coverage-grid { display: grid; gap: 12px; }
.coverage-item { display: flex; align-items: center; gap: 12px; }
.coverage-label { width: 120px; font-weight: 600; font-size: 0.9rem; }
.coverage-bar-bg { flex: 1; background: #f1f5f9; border-radius: 8px; height: 28px; overflow: hidden; }
.coverage-bar { background: #2563eb; height: 100%; border-radius: 8px; display: flex; align-items: center; padding: 0 12px; color: white; font-weight: 600; font-size: 0.8rem; min-width: 30px; transition: width 0.5s; }

/* === Fairness === */
.fairness-list { display: grid; gap: 8px; }
.fairness-item { display: flex; align-items: center; gap: 12px; position: relative; padding: 8px 12px; background: #f8fafc; border-radius: 8px; }
.fairness-rank { font-weight: 700; color: #2563eb; width: 30px; }
.fairness-name { font-weight: 600; width: 120px; }
.fairness-count { font-size: 0.85rem; color: #64748b; width: 100px; }
.fairness-bar { position: absolute; left: 0; top: 0; height: 100%; background: #dbeafe; border-radius: 8px; z-index: -1; transition: width 0.5s; }

/* === Date Chips (Rota) === */
.date-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.date-chip { display: inline-block; padding: 4px 12px; border-radius: 20px; background: #eff6ff; color: #2563eb; font-size: 0.85rem; font-weight: 500; }
.chip-past { background: #f1f5f9; color: #94a3b8; }

/* === Alerts === */
.flash-messages { margin-bottom: 16px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 0.9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.text-muted { color: #94a3b8; }

/* === HTMX Indicator === */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

/* === Feedback Metrics === */
.feedback-metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.metric-item { text-align: center; }
.metric-value { font-size: 1.8rem; font-weight: 700; color: #2563eb; }
.metric-value.metric-positive { color: #10b981; }
.metric-label { font-size: 0.8rem; color: #64748b; margin-top: 2px; }
.metric-sub { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.metric-bar { height: 6px; background: #f1f5f9; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.metric-fill { height: 100%; background: #2563eb; border-radius: 3px; transition: width 0.5s; }
.feedback-stars-grid { display: grid; gap: 8px; }
.feedback-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.feedback-row label { font-size: 0.85rem; font-weight: 500; min-width: 130px; }
.feedback-scores { display: flex; gap: 8px; font-size: 0.8rem; font-weight: 600; color: #475569; }
.feedback-scores span { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }

/* === Topic Explorer === */
.explore-card { background: #f8fafc; border-radius: 8px; padding: 12px; margin-bottom: 8px; border-left: 3px solid #2563eb; }
.explore-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.explore-why { font-size: 0.8rem; color: #475569; line-height: 1.4; margin-bottom: 6px; }
.explore-papers { display: flex; flex-direction: column; gap: 2px; }
.explore-paper-link { font-size: 0.78rem; color: #2563eb; text-decoration: none; }
.explore-paper-link:hover { text-decoration: underline; }

/* === Year Pills === */
.year-pills { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.year-pill { padding: 6px 18px; border-radius: 20px; font-weight: 600; font-size: 0.9rem; color: #475569; background: #f1f5f9; text-decoration: none; transition: all 0.15s; }
.year-pill:hover { background: #e2e8f0; text-decoration: none; color: #1e293b; }
.year-pill.active { background: #2563eb; color: white; }
.year-pill-archive { background: transparent; color: #64748b; border: 1px dashed #cbd5e1; }
.year-pill-archive:hover { border-color: #94a3b8; color: #475569; }

/* === Archive === */
.archive-year-row td { background: #f1f5f9; padding: 8px 14px !important; font-size: 1rem; color: #2563eb; }

/* === Rota === */
.rota-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.rota-red { background: #ef4444; }
.rota-orange { background: #f59e0b; }
.rota-green { background: #10b981; }
.rota-activity { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; }
.rota-activity-red { background: #fee2e2; color: #991b1b; }
.rota-activity-orange { background: #fef3c7; color: #92400e; }
.rota-activity-green { background: #f0fdf4; color: #166534; }
.rota-row-red { background: #fff5f5; }
.rota-row-orange { background: #fffbeb; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* === Footer === */
.footer { text-align: center; padding: 24px; margin-top: 48px; color: #94a3b8; font-size: 0.8rem; border-top: 1px solid #e2e8f0; }

/* === Responsive === */
@media (max-width: 768px) {
    .navbar { flex-direction: column; gap: 8px; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .session-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .builder-layout { grid-template-columns: 1fr; }
    .session-meta { grid-template-columns: 1fr; }
    .filters-form { flex-direction: column; }
    .filters-form input, .filters-form select { width: 100%; }
    .input-search { max-width: 100%; }
}
