/* ============================================================================
 * Vispa Desk PWA — Graphite Theme & Android-Identical UI Styles
 * ============================================================================ */
@font-face {
  font-family: 'PeydaWebFaNum';
  src: url('../assets/PeydaWebFaNum-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'PeydaWebFaNum';
  src: url('../assets/PeydaWebFaNum-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'PeydaWebFaNum';
  src: url('../assets/PeydaWebFaNum-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'PeydaWebFaNum';
  src: url('../assets/PeydaWebFaNum-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root,
[data-theme="dark"] {
  --bg: #111414;
  --surface: #191D1D;
  --raised: #222727;
  --border: #38403F;
  --ink: #F4F5F3;
  --secondary: #BABEBC;
  --accent: #6AA9FF;
  --on-accent: #06182F;
  --selected: #17345B;
  --ok: #46D993;
  --warn: #F4BE50;
  --danger: #FF6E6E;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg: #F6F8F6;
  --surface: #FFFFFF;
  --raised: #EEF2EE;
  --border: #CFD6D0;
  --ink: #17201A;
  --secondary: #4C594E;
  --accent: #1D64D8;
  --on-accent: #FFFFFF;
  --selected: #DCE9FF;
  --ok: #137A4B;
  --warn: #B86B00;
  --danger: #C62828;
  --shadow: 0 8px 24px rgba(23, 32, 26, 0.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--ink);
  font-family: 'PeydaWebFaNum', system-ui, -apple-system, sans-serif;
  direction: rtl;
  user-select: none;
  -webkit-user-select: none;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

.ltr-center {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}

/* App Shell Layout */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  background: var(--bg);
  position: relative;
}

/* Top Banners (Active Session / Announcements / Toast) */
.top-banners {
  flex-shrink: 0;
  z-index: 40;
}

.session-return-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--selected);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.toast-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--raised);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

/* Main Scrollable Page Area */
.page-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px 24px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-container.session-mode {
  max-width: 100%;
  padding: 0;
  overflow: hidden;
}

/* Header & Brand */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: contain;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--warn);
}
.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

/* Cards & Dividers */
.g-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.g-line {
  height: 1px;
  background: var(--border);
  width: 100%;
  margin: 2px 0;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 4px 0 2px;
}

.text-muted {
  color: var(--secondary);
  font-size: 12.5px;
  line-height: 1.55;
}

/* Device Code Display */
.my-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.my-code-digits {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}

/* Form Inputs & Buttons */
.g-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.g-field {
  width: 100%;
  height: 48px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.g-field:focus {
  border-color: var(--accent);
}

.g-field.code-input {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  direction: ltr;
}

.btn-primary {
  height: 48px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 11px;
  padding: 0 18px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-outline {
  height: 42px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-outline:hover:not(:disabled) {
  background: var(--raised);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-text:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.badge-dot {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Bottom Navigation Bar */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 62px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 30;
}

.nav-item {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.nav-item.active {
  color: var(--accent);
  font-weight: 700;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Device List Rows */
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.device-row:hover {
  border-color: var(--accent);
}

/* ============================================================================
 * Session Screen — Remote Viewport, MousePointer & Floating Docks
 * ============================================================================ */
.session-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #000;
  position: relative;
  overflow: hidden;
}

.session-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.session-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12.5px;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--secondary);
  cursor: pointer;
  white-space: nowrap;
}

.session-tab.active {
  background: var(--selected);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.session-stage {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  background: #090b0b;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.canvas-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#remote-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 50% 50%;
  will-change: transform;
  pointer-events: none;
}

/* Custom Android MousePointer Overlay */
.mouse-pointer {
  position: absolute;
  top: 0;
  left: 0;
  width: 30px;
  height: 30px;
  pointer-events: none;
  z-index: 25;
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.65));
}

.mouse-pointer.dragging svg path:last-child {
  fill: var(--accent);
}

/* Floating Draggable & Flippable SessionDock (1:1 with SessionScreen.kt) */
.session-dock {
  position: absolute;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  touch-action: none;
  transition: border-radius 0.15s;
}

.session-dock.side-right {
  right: 0;
  border-radius: 24px 0 0 24px;
  border-right: none;
}

.session-dock.side-left {
  left: 0;
  border-radius: 0 24px 24px 0;
  border-left: none;
}

.session-dock .dock-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-height: 76dvh;
  overflow-y: auto;
  scrollbar-width: none;
}
.session-dock .dock-items::-webkit-scrollbar {
  display: none;
}

.session-dock .icon-btn {
  color: #fff;
  width: 38px;
  height: 38px;
}

.session-dock .icon-btn.active-toggle {
  background: rgba(106, 169, 255, 0.28);
  color: #6AA9FF;
}

.session-dock .icon-btn.danger {
  color: #FF6E6E;
}

/* Hidden IME Anchor Input for Mobile Virtual Keyboard */
#remote-ime-input {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  z-index: -1;
}

/* Modals / Dialogs */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 430px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* Chat Bubbles */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}

.chat-row {
  display: flex;
  width: 100%;
}
.chat-row.mine {
  justify-content: flex-start;
}
.chat-row.peer {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--raised);
  border: 1px solid var(--border);
  font-size: 13.5px;
  cursor: pointer;
}
.chat-row.mine .chat-bubble {
  background: var(--selected);
  border-color: rgba(106, 169, 255, 0.35);
}

.chat-quote {
  background: rgba(0, 0, 0, 0.25);
  border-right: 3px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--secondary);
}

/* Connecting Stepper */
.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13.5px;
}
.step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--secondary);
}
.step-dot.done {
  background: var(--ok);
  border-color: var(--ok);
  color: #062012;
}
.step-dot.current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
