/* ========================================================
   Metaforinių Kortų Webapp (MAK) - Pagrindiniai Stiliai
   ======================================================== */

:root {
  --bg-space: #0d131a;
  --bg-table: radial-gradient(circle at 50% 50%, #1a2736 0%, #0e1722 100%);
  --panel-bg: rgba(18, 28, 39, 0.88);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-glass: blur(16px);
  --gold: #dfba73;
  --gold-hover: #f3d494;
  --gold-glow: rgba(223, 186, 115, 0.25);
  --text-main: #f0f4f8;
  --text-muted: #94a3b8;
  --card-w: 160px;
  --card-h: 234px;
  --accent: #38bdf8;
  --danger: #ef4444;
  --success: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-space);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ================= HEADER ================= */
.app-header {
  height: 64px;
  background: var(--panel-bg);
  backdrop-filter: var(--panel-glass);
  -webkit-backdrop-filter: var(--panel-glass);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
  gap: 1rem;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--gold) 0%, #b8862d 100%);
  border-radius: 8px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 12px var(--gold-glow);
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  fill: #111;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gold);
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

/* Toolbar Controls */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.select-custom {
  background: #16222f;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.select-custom:hover,
.select-custom:focus {
  border-color: var(--gold);
  background: #1c2c3d;
}

.select-custom option {
  background-color: #16222f;
  color: #f0f4f8;
  padding: 8px 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, #c49942 100%);
  color: #121820;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--gold-glow);
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-hover) 0%, #d4a74c 100%);
  box-shadow: 0 4px 14px rgba(223, 186, 115, 0.4);
}

.btn-icon-only {
  padding: 0.45rem;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
}

.room-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ================= WORKSPACE TABLETOP ================= */
.workspace-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-table);
}

.table-surface {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(rgba(223, 186, 115, 0.05) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px, 80px 80px;
  background-position: 0 0, 20px 20px;
}

/* Slot Placeholders (Spreads) */
.spread-slot {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border: 2px dashed rgba(223, 186, 115, 0.3);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.15);
  transition: all 0.3s;
}

.spread-slot-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.3rem;
}

.spread-slot-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* ================= CARDS ON TABLE ================= */
.card-item {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 12px;
  cursor: grab;
  perspective: 1000px;
  transform-origin: center center;
  transition: box-shadow 0.2s, transform 0.1s ease-out;
  touch-action: none;
}

.card-item:active {
  cursor: grabbing;
}

.card-item.selected {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.card-item.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-face img, .card-face svg {
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.card-back {
  background: #141e30;
}

.card-front {
  background: #243b55;
  transform: rotateY(180deg);
}

/* Card Controls */
.card-actions {
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  background: #14202d;
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 3px 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: 100;
}

/* Tiltas, kad pelė judėdama link mygtukų neprarastų hover */
.card-actions::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 20px;
}

.card-item:hover .card-actions,
.card-item.selected .card-actions {
  opacity: 1;
  pointer-events: auto;
}

.card-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 4px 6px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.card-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--gold);
}

/* Attached OH Word Ribbon */
.card-word-overlay {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
  z-index: 20;
  white-space: nowrap;
}

/* Standalone draggable OH Word card */
.word-item {
  position: absolute;
  background: #ffffff;
  color: #111827;
  border: 2px solid #000000;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 2px;
  cursor: grab;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  touch-action: none;
  text-transform: uppercase;
  z-index: 25;
}

.word-item:active {
  cursor: grabbing;
}

/* ================= SIDE DRAWER (Vedlys & Užrašai) ================= */
.drawer {
  position: fixed;
  top: 64px;
  right: -380px;
  width: 380px;
  height: calc(100vh - 64px);
  background: var(--panel-bg);
  backdrop-filter: var(--panel-glass);
  border-left: 1px solid var(--panel-border);
  box-shadow: -8px 0 25px rgba(0, 0, 0, 0.5);
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  right: 0;
}

.drawer-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h2 {
  font-size: 1.05rem;
  color: var(--gold);
  font-weight: 600;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Coach Question Box */
.question-box {
  background: rgba(223, 186, 115, 0.08);
  border: 1px solid rgba(223, 186, 115, 0.2);
  border-radius: 10px;
  padding: 1rem;
}

.question-stage {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.question-text {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-main);
  font-style: italic;
  margin-bottom: 0.75rem;
}

/* Notes Field */
.notes-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.notes-area {
  width: 100%;
  height: 140px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  resize: vertical;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.notes-area:focus {
  border-color: var(--gold);
}

/* Ethics Box */
.ethics-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ethics-box h4 {
  color: var(--gold);
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}

.ethics-box ul {
  padding-left: 1.2rem;
  line-height: 1.45;
}

/* ================= MODAL DIALOGS ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.open {
  display: grid;
}

.modal-box {
  background: #141f2d;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 1.15rem;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.copy-link-box {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.copy-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

/* Preview Modal */
.preview-modal .modal-box {
  max-width: 380px;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

.preview-modal img, .preview-modal svg {
  max-width: 100%;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--panel-bg);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.6rem 1.25rem;
  border-radius: 30px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Mobile Bottom Bar (hidden by default on desktop) */
.mobile-bottom-bar {
  display: none;
}

/* ================= RESPONSIVE (MOBILE & TABLET) ================= */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .app-header {
    height: auto;
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .header-top {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .brand {
    gap: 0.6rem;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .brand-text span {
    font-size: 0.62rem;
  }

  .toolbar {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
  }

  .tool-group.select-group {
    flex: 1 1 50%;
    min-width: 0;
    width: 50%;
    background: transparent;
    padding: 0;
    border: none;
  }

  .select-custom {
    width: 100%;
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .room-badge {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  /* Fixed Bottom Bar on Mobile */
  .mobile-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(14, 23, 34, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--panel-border);
    z-index: 70;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.5rem;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .m-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .m-nav-btn:active {
    background: rgba(255, 255, 255, 0.1);
  }

  .m-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
  }

  .m-nav-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
  }

  .m-nav-gold .m-nav-label {
    color: var(--gold);
    font-weight: 600;
  }

  /* Table padding so bottom bar doesn't obscure cards */
  .workspace-container {
    padding-bottom: 60px;
  }

  /* Responsive Cards */
  :root {
    --card-w: 110px;
    --card-h: 160px;
  }

  .card-actions {
    top: -46px;
    padding: 4px 10px;
    gap: 8px;
  }

  .card-btn {
    padding: 6px 8px;
    font-size: 1rem;
  }

  /* Full screen drawer on mobile */
  .drawer {
    top: 0;
    right: -100%;
    width: 100%;
    height: 100vh;
    z-index: 150;
  }

  .drawer.open {
    right: 0;
  }

  .spread-slot {
    padding: 0.5rem;
  }

  .spread-slot-title {
    font-size: 0.72rem;
  }

  .spread-slot-desc {
    font-size: 0.6rem;
  }
}

@media (max-width: 420px) {
  :root {
    --card-w: 96px;
    --card-h: 140px;
  }
}
