/* R2C Community — style.css */
:root {
    --bg: #0a0a0f;
    --bg-card: #141420;
    --bg-card-hover: #1a1a2e;
    --border: #2a2a3e;
    --gold: #c9a84c;
    --gold-light: #e0bb5a;
    --teal: #2bbfa7;
    --ok: #2bd36b;
    --err: #e25b5b;
    --text: #e8e8ea;
    --text-muted: #9a9aa8;
    --text-dim: #6a6a78;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--gold-light); text-decoration: none; }
a:hover { color: var(--gold); }
.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }
.center { text-align: center; }
.err { color: var(--err); }
.ok { color: var(--ok); }
.hidden { display: none !important; }
img { max-width: 100%; }

/* Header */
.app-header {
    display: flex; align-items: center; gap: 20px;
    padding: 10px 24px; background: linear-gradient(135deg, #1a1a2e, #141420);
    border-bottom: 1px solid var(--gold); height: 56px;
    position: sticky; top: 0; z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--gold); font-size: 1.1em; }
.brand img { height: 32px; }
.top-nav { display: flex; gap: 18px; margin-left: 20px; }
.top-nav a { color: var(--text); font-weight: 500; }
.top-nav a:hover { color: var(--gold-light); }
.user-menu { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 0.9em; }
.user-level { background: var(--gold); color: #0a0a0f; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 0.8em; }
.user-pts { color: var(--gold-light); font-weight: 600; }
.user-name { color: var(--text); font-weight: 500; }
.logout-btn { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); }
.logout-btn:hover { background: rgba(226,91,91,.1); border-color: var(--err); color: var(--err); }

/* Main layout */
.app-main { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: var(--bg-card); padding: 20px 14px; border-right: 1px solid var(--border); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: var(--text); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(201,168,76,.12); color: var(--gold-light); }
.sidebar-section { margin-top: 24px; }
.sidebar-section h4 { color: var(--gold); font-size: 0.75em; letter-spacing: 1.5px; text-transform: uppercase; margin: 0 0 8px; padding: 0 8px; }
.sidebar-course { display: block; padding: 6px 12px; color: var(--text-muted); font-size: 0.88em; border-radius: 6px; }
.sidebar-course:hover { background: rgba(201,168,76,.08); color: var(--text); }

.content { padding: 28px 36px; max-width: 1100px; margin: 0 auto; width: 100%; }
.content h1 { color: var(--gold); border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-top: 0; }
.content h2 { color: var(--gold-light); margin-top: 32px; }

.back-link { color: var(--text-muted); font-size: 0.9em; display: inline-block; margin-bottom: 16px; }
.back-link:hover { color: var(--gold-light); }

/* Dashboard Widgets */
.welcome-card {
    background: linear-gradient(135deg, rgba(201,168,76,.08), rgba(43,191,167,.05));
    border: 1px solid var(--gold); border-radius: 14px; padding: 24px 28px; margin-bottom: 24px;
}
.welcome-card h1 { border: none; padding: 0; margin: 0 0 8px; font-size: 1.6em; }
.level-progress { margin-top: 14px; }
.level-bar { background: var(--bg); border-radius: 999px; height: 8px; overflow: hidden; }
.level-fill { background: linear-gradient(90deg, var(--gold), var(--gold-light)); height: 100%; transition: width .3s; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.widget { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.widget h3 { margin: 0 0 14px; color: var(--gold); font-size: 1em; }

.course-card { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 10px; margin-bottom: 6px; color: var(--text); }
.course-card:hover { background: var(--bg-card-hover); }
.course-icon { font-size: 2em; }
.course-card p { margin: 2px 0 0; }

.leader-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 0.9em; }
.leader-row:last-child { border: none; }
.leader-rank { color: var(--gold); font-weight: 700; }
.leader-pts { color: var(--text-muted); font-size: 0.85em; }

.feed-row { display: flex; justify-content: space-between; padding: 10px; border-radius: 8px; align-items: center; color: var(--text); }
.feed-row:hover { background: var(--bg-card-hover); }

/* Forms */
input, textarea, select, button {
    font-family: inherit; font-size: 1em;
}
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], textarea, select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; color: var(--text); margin-bottom: 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }
label { display: block; color: var(--text-muted); font-size: 0.85em; margin-bottom: 5px; margin-top: 8px; }
.btn-primary, .btn-secondary, .btn-ghost, .btn-mini {
    display: inline-block; border: none; border-radius: 8px;
    padding: 10px 20px; cursor: pointer; font-weight: 600; font-size: 0.95em;
    transition: all .15s; text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: #0a0a0f; }
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 3px 12px rgba(201,168,76,.35); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--gold); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 6px 12px; }
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }
.btn-mini { padding: 4px 10px; font-size: 0.8em; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-mini:hover { background: var(--bg-card-hover); border-color: var(--gold); }

/* Auth page */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
    background: var(--bg-card); border: 1px solid var(--gold); border-radius: 18px;
    padding: 36px 32px; max-width: 420px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { height: 52px; margin-bottom: 8px; }
.auth-logo h1 { color: var(--gold); margin: 4px 0 2px; font-size: 1.4em; }
.auth-logo p { margin: 0; font-size: 0.85em; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { flex: 1; background: transparent; color: var(--text-muted); border: none; padding: 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-body { display: block; }
.auth-msg { margin-top: 12px; min-height: 20px; text-align: center; font-size: 0.88em; }
.auth-hint { color: var(--text-dim); font-size: 0.78em; margin-top: 16px; text-align: center; }

/* Course page */
.course-hero { display: flex; gap: 20px; align-items: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; margin-bottom: 24px; }
.course-hero-icon { font-size: 3em; }
.course-progress { margin-top: 12px; max-width: 400px; }
.module-list { display: flex; flex-direction: column; gap: 8px; }
.module-card { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.module-card:hover { border-color: var(--gold); background: var(--bg-card-hover); }
.module-card.done { border-color: rgba(43,211,107,.4); }
.module-nr { background: var(--bg); color: var(--gold); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.module-card.done .module-nr { background: rgba(43,211,107,.15); color: var(--ok); }
.module-status { margin-left: auto; font-size: 1.2em; }

/* Module page */
.video-wrap { position: relative; padding-bottom: 56.25%; background: #000; border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.video-wrap iframe, .video-wrap video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.module-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 24px 28px; margin-bottom: 24px; line-height: 1.7; }
.module-content h2, .module-content h3 { color: var(--gold-light); }
.module-actions { text-align: center; margin-top: 20px; }
.badge-done { background: rgba(43,211,107,.15); color: var(--ok); padding: 10px 20px; border-radius: 999px; font-weight: 600; }

/* Feed */
.new-post { margin-bottom: 20px; }
.new-post summary { display: inline-block; cursor: pointer; list-style: none; }
.new-post summary::-webkit-details-marker { display: none; }
.new-post[open] summary { margin-bottom: 14px; }
.new-post form { background: var(--bg-card); padding: 18px; border-radius: 12px; border: 1px solid var(--border); }

.post-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; margin-bottom: 14px; }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.avatar { background: linear-gradient(135deg, var(--gold), var(--teal)); color: #0a0a0f; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.avatar.small { width: 28px; height: 28px; font-size: 0.85em; }
.avatar.big { width: 56px; height: 56px; font-size: 1.4em; }
.post-card h3 { margin: 6px 0; }
.post-card h3 a { color: var(--gold-light); }
.post-body { color: var(--text); margin: 10px 0; }
.post-actions { display: flex; gap: 14px; padding-top: 10px; border-top: 1px solid var(--border); }

.pill { background: rgba(201,168,76,.15); color: var(--gold-light); padding: 2px 10px; border-radius: 999px; font-size: 0.75em; }
.pill.ok { background: rgba(43,211,107,.15); color: var(--ok); }
.pill.pinned { background: rgba(226,91,91,.1); color: var(--err); }

.comments { margin-top: 14px; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment-body { flex: 1; }
.comment-body > div { margin-top: 6px; }

/* Members */
.members-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.member-card { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; position: relative; }
.member-rank { position: absolute; top: 8px; right: 10px; font-size: 0.75em; color: var(--text-dim); }
.member-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }

/* Admin */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 24px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-align: center; }
.stat b { color: var(--gold); font-size: 1.8em; display: block; }
.stat span { color: var(--text-muted); font-size: 0.8em; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9em; margin-bottom: 20px; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--gold); font-weight: 600; background: var(--bg-card); }
.admin-table .big-icon { font-size: 1.4em; }
.admin-table input { width: auto; max-width: 90px; padding: 4px 8px; margin: 0; }
.admin-table input[type=checkbox] { width: auto; }
.admin-table.nested { margin: 10px 0; }
.modules-row { background: rgba(0,0,0,.2); }
.new-form { margin-bottom: 16px; }
.new-form summary { display: inline-block; list-style: none; cursor: pointer; }
.new-form summary::-webkit-details-marker { display: none; }
.new-form form { background: var(--bg-card); padding: 16px; border-radius: 10px; margin-top: 10px; border: 1px solid var(--border); }

/* Dialog */
dialog { background: var(--bg-card); color: var(--text); border: 1px solid var(--gold); border-radius: 14px; padding: 24px 28px; max-width: 600px; width: 90%; }
dialog::backdrop { background: rgba(0,0,0,.8); backdrop-filter: blur(4px); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Responsive */
@media (max-width: 820px) {
    .app-main { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .top-nav { display: none; }
    .content { padding: 16px; }
    .course-hero { flex-direction: column; text-align: center; }
}
