/* ─── Reset & Base ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1f2940;
  --bg-input: #0f1729;
  --text-primary: #e0e0e0;
  --text-secondary: #8892a4;
  --text-muted: #5a6478;
  --accent-red: #e94560;
  --accent-green: #4ecca3;
  --accent-blue: #3a86ff;
  --accent-orange: #ff9f43;
  --border-color: #2a3550;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,.3);
  --transition: .2s ease;
  --nav-height: 64px;
  --topbar-height: 56px;
}
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Overlay ──────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,10,20,.92);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.overlay.hidden { display: none; }
.overlay-content { text-align: center; color: var(--text-primary); }
.overlay-content h2 { margin: 16px 0 8px; font-size: 20px; }
.overlay-content p { color: var(--text-secondary); }
.overlay-icon { color: var(--accent-red); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Views ────────────────────────────────── */
.view { height: 100%; }
.view.hidden { display: none; }

/* ─── Auth ─────────────────────────────────── */
.auth-container {
  max-width: 400px; margin: 0 auto; padding: 40px 24px;
  display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; justify-content: center;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo svg { display: block; margin: 0 auto 12px; }
.auth-logo h1 { font-size: 28px; font-weight: 700; letter-spacing: 2px; }
.auth-form { width: 100%; }
.auth-form.hidden { display: none; }
.auth-form h2 { text-align: center; margin-bottom: 24px; font-size: 20px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--text-secondary); font-size: 14px; }
.auth-switch a { color: var(--accent-blue); text-decoration: none; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="datetime-local"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%; padding: 12px 16px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 15px; outline: none; transition: border var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent-blue);
}
.form-group textarea { resize: vertical; min-height: 60px; }

.role-select span { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 13px; }
.role-buttons { display: flex; gap: 8px; }
.role-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; border: 2px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-secondary); cursor: pointer;
  font-size: 14px; transition: all var(--transition);
}
.role-btn.active { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(58,134,255,.1); }
.role-btn:hover { border-color: var(--accent-blue); }

.error-msg { color: var(--accent-red); font-size: 13px; text-align: center; margin-top: 12px; }
.error-msg.hidden { display: none; }

/* ─── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); outline: none;
}
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #2a76ef; }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent-blue); }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #d63050; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition); position: relative;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }
.icon-btn.danger:hover { color: var(--accent-red); }

/* ─── Top Bar ──────────────────────────────── */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height);
  background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 100;
}
.top-bar-left, .top-bar-right { display: flex; align-items: center; gap: 8px; }
.top-bar-center { display: flex; align-items: center; gap: 6px; }
.avatar-small {
  width: 32px; height: 32px; border-radius: 50%; background: var(--bg-card);
  background-size: cover; background-position: center;
  border: 2px solid var(--border-color);
}
.display-name { font-size: 14px; font-weight: 600; }
.partner-name { font-size: 13px; color: var(--text-secondary); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.status-dot.online { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.offline { background: var(--text-muted); }

.badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent-red); color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.badge.hidden { display: none; }

/* ─── Bottom Nav ───────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height);
  background: var(--bg-secondary); border-top: 1px solid var(--border-color);
  display: flex; z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 11px; transition: color var(--transition); padding: 4px;
}
.nav-btn.active { color: var(--accent-blue); }
.nav-btn:hover { color: var(--text-primary); }
.nav-btn svg { flex-shrink: 0; }

/* ─── Pages Container ──────────────────────── */
.pages-container {
  position: absolute;
  top: var(--topbar-height); bottom: var(--nav-height);
  left: 0; right: 0; overflow-y: auto; overflow-x: hidden;
  padding: 16px;
}
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-header h2 { font-size: 20px; font-weight: 700; }

/* ─── Cards ────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
  border: 1px solid var(--border-color);
}
.card h3 { font-size: 16px; margin-bottom: 12px; font-weight: 600; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header-row h3 { margin-bottom: 0; }

/* ─── Dashboard grid ───────────────────────── */
.dashboard-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px;
}
.status-card {
  display: flex; align-items: center; gap: 12px; padding: 16px;
}
.card-icon { flex-shrink: 0; color: var(--accent-blue); }
.card-icon.permission-icon { color: var(--text-muted); }
.card-icon.permission-icon.allowed { color: var(--accent-green); }
.card-icon.permission-icon.denied { color: var(--accent-red); }
.card-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.card-value { font-size: 16px; font-weight: 600; }

/* ─── Invite section ───────────────────────── */
.invite-display { text-align: center; }
.invite-display p { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.invite-code-box {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 12px;
}
.invite-code-box span {
  font-size: 24px; font-weight: 700; letter-spacing: 4px; color: var(--accent-blue);
  font-family: monospace;
}
.invite-input-row { display: flex; gap: 8px; }
.invite-input-row input { flex: 1; text-transform: uppercase; letter-spacing: 2px; text-align: center; font-size: 18px; }

/* ─── Session ──────────────────────────────── */
.session-header { display: flex; align-items: center; justify-content: space-between; }
.session-status-badge {
  display: inline-block; padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.session-status-badge.active { background: rgba(78,204,163,.15); color: var(--accent-green); }
.session-status-badge.paused { background: rgba(255,159,67,.15); color: var(--accent-orange); }
.session-status-badge.pending { background: rgba(58,134,255,.15); color: var(--accent-blue); }
.session-timer { margin-left: 12px; font-size: 20px; font-weight: 700; font-family: monospace; }
.session-controls { display: flex; gap: 4px; }
.session-settings { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-color); }

.empty-state { text-align: center; padding: 32px 16px; }
.empty-state svg { margin-bottom: 12px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 16px; }
.empty-hint { color: var(--text-muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* ─── Tasks ────────────────────────────────── */
.tasks-list { display: flex; flex-direction: column; gap: 8px; }
.task-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-input); border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.task-item.completed { opacity: .6; }
.task-check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-color);
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.task-check:hover { border-color: var(--accent-green); }
.task-check.done { background: var(--accent-green); border-color: var(--accent-green); }
.task-check.done svg { display: block; }
.task-check svg { display: none; }
.task-body { flex: 1; }
.task-title { font-size: 14px; font-weight: 500; }
.task-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.task-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
  background: rgba(58,134,255,.15); color: var(--accent-blue);
}
.task-badge.mandatory { background: rgba(233,69,96,.15); color: var(--accent-red); }

/* ─── Media grid ───────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.media-item {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-input); border: 1px solid var(--border-color);
  cursor: pointer;
}
.media-item img, .media-item video {
  width: 100%; height: 100%; object-fit: cover;
}
.media-item.blurred img, .media-item.blurred video { filter: blur(20px); pointer-events: none; }
.media-item.destroyed { display: none; }
.media-timer-badge {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 11px;
  padding: 2px 6px; border-radius: 4px;
}
.media-lock-icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: rgba(255,255,255,.6);
}

/* ─── Orgasm section ───────────────────────── */
.orgasm-section {
  margin-top: 12px; padding: 12px; background: var(--bg-input);
  border-radius: var(--radius-sm); display: flex; align-items: center; gap: 8px;
}
.orgasm-hidden { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.orgasm-revealed { display: flex; align-items: center; gap: 8px; color: var(--accent-green); font-weight: 600; }
.orgasm-revealed.hidden { display: none; }

/* ─── Tickets ──────────────────────────────── */
.tickets-container { display: flex; flex-direction: column; gap: 12px; }
.ticket-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius); padding: 16px;
}
.ticket-card h4 { font-size: 15px; margin-bottom: 8px; }
.ticket-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.ticket-tasks { font-size: 13px; color: var(--text-secondary); }

/* ─── Log ──────────────────────────────────── */
.stats-row { display: flex; gap: 16px; }
.stat-item { flex: 1; text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent-blue); }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 12px; display: flex; align-items: center; gap: 12px;
}
.log-item-icon { flex-shrink: 0; color: var(--accent-orange); }
.log-item-body { flex: 1; }
.log-item-type { font-size: 14px; font-weight: 500; }
.log-item-time { font-size: 12px; color: var(--text-secondary); }
.log-item-comment { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Settings ─────────────────────────────── */
.toggle-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; cursor: pointer;
}
.toggle-row span { font-size: 14px; }
.toggle-switch {
  position: relative; width: 48px; height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 26px;
  background: var(--border-color); transition: var(--transition); cursor: pointer;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

.avatar-upload-row { display: flex; align-items: center; gap: 12px; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-input); background-size: cover; background-position: center;
  border: 2px solid var(--border-color);
}

/* ─── Dictionary ───────────────────────────── */
.hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.dictionary-list { margin-bottom: 12px; }
.dict-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}
.dict-item:last-child { border-bottom: none; }
.dict-arrow { color: var(--text-muted); margin: 0 8px; }
.form-row { display: flex; gap: 8px; align-items: flex-end; }
.input-half { flex: 1; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; outline: none; }
.input-half:focus { border-color: var(--accent-blue); }

.filters-list { list-style: none; }
.filters-list li {
  padding: 8px 0; border-bottom: 1px solid var(--border-color);
  font-size: 14px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px;
}
.filters-list li svg { flex-shrink: 0; color: var(--accent-orange); }
.filters-edit .filter-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border-color);
}
.filter-item span { flex: 1; font-size: 14px; }

/* ─── Control Grid ─────────────────────────── */
.control-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* ─── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 24px; max-width: 480px; width: 100%;
  max-height: 80vh; overflow-y: auto;
}
.modal-content h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

/* ─── Toast ────────────────────────────────── */
.toast-container {
  position: fixed; top: calc(var(--topbar-height) + 8px);
  right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow); animation: slideIn .3s ease;
  max-width: 320px; display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }
.toast-text { font-size: 13px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Replaceable words ────────────────────── */
.dict-word { cursor: help; border-bottom: 1px dotted var(--text-muted); }

/* ─── Helpers ──────────────────────────────── */
.hidden { display: none !important; }
.girl-only { }

/* ─── Responsive (desktop) ─────────────────── */
@media (min-width: 768px) {
  .auth-container { padding: 60px 24px; }
  .pages-container { max-width: 720px; margin: 0 auto; padding: 24px; }
  .bottom-nav { left: 50%; transform: translateX(-50%); max-width: 720px; border-radius: var(--radius) var(--radius) 0 0; }
  .top-bar { max-width: 720px; left: 50%; transform: translateX(-50%); border-radius: 0 0 var(--radius) var(--radius); }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .pages-container { max-width: 800px; }
  .bottom-nav, .top-bar { max-width: 800px; }
  .dashboard-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Scrollbar ────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
