/* ════════════════════════════════════════════════════════════════
   Kidan Desktop Web App Stylesheet (webapp.css)
   Desktop layout overrides for 3-column split view dating companion
   ════════════════════════════════════════════════════════════════ */

:root {
  --sidebar-w: 260px;
  --detail-w: 400px;
  --shell-bg: #0d0820;
  --hover-bg: rgba(255, 255, 255, 0.05);
  --active-bg: rgba(139, 92, 246, 0.15);
}

body.desktop-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
}

/* ════════════ Desktop 3-Column Grid ════════════ */
@media (min-width: 900px) {
  #desktop-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--detail-w);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg);
  }

  /* 1. Left Sidebar */
  #desktop-sidebar {
    background: var(--shell-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 10;
  }

  .sidebar-brand {
    padding: 0 12px;
    margin-bottom: 36px;
  }

  .sidebar-brand-ge {
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--rose), var(--violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .sidebar-brand-en {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
  }

  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    width: 100%;
  }

  .sidebar-item:hover {
    background: var(--hover-bg);
    color: var(--text);
  }

  .sidebar-item.active {
    background: var(--active-bg);
    color: var(--rose);
    border: 1px solid rgba(217, 70, 239, 0.25);
  }

  .sidebar-icon {
    font-size: 18px;
    flex-shrink: 0;
  }

  .sidebar-badge {
    background: var(--rose);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: auto;
  }

  .sidebar-spacer {
    flex: 1;
  }

  .sidebar-vip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 8px 0;
    background: linear-gradient(135deg, rgba(240,199,94,0.12), rgba(217,70,239,0.08));
    border: 1px solid rgba(240,199,94,0.25);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
  }

  .sidebar-vip:hover {
    border-color: rgba(240,199,94,0.5);
    background: linear-gradient(135deg, rgba(240,199,94,0.18), rgba(217,70,239,0.12));
  }

  .sidebar-vip-icon { font-size: 20px; }
  .sidebar-vip-title { font-size: 13px; font-weight: 800; color: var(--gold); }
  .sidebar-vip-sub { font-size: 11px; color: var(--text-muted); }

  .sidebar-bottom {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  .sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
  }

  .sidebar-user:hover {
    background: var(--hover-bg);
  }

  .sidebar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
  }

  .sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .sidebar-user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-user-status {
    font-size: 11px;
    color: var(--text-muted);
  }

  /* 2. Main Content Area (Center Column) */
  #desktop-main {
    position: relative;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
  }

  #desktop-main #app {
    position: relative;
    width: 100%;
    height: 100%;
  }

  #desktop-main #nav {
    display: none !important;
  }

  #desktop-main .screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #desktop-main .screen.has-nav {
    padding-bottom: 0 !important;
  }

  .app-header {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px 16px;
  }

  #deck-zone {
    width: 100%;
    max-width: 440px;
    margin: 10px auto;
    flex: 1;
    position: relative;
  }

  .swipe-card {
    max-width: 440px;
    margin: 0 auto;
  }

  #deck-actions {
    width: 100%;
    max-width: 440px;
    margin: 0 auto 24px auto;
    justify-content: space-evenly;
  }

  /* Onboarding Glassmorphism Containers.
     Scoped to .active: an unscoped ID selector here beat .screen{display:none}
     and left every onboarding step laid out at once, so the previous step's
     buttons floated on top of the current one. */
  #scr-phone.active, #scr-otp.active, #scr-setup.active,
  #scr-splash.active, #scr-lang.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  #scr-phone:not(.active), #scr-otp:not(.active), #scr-setup:not(.active),
  #scr-splash:not(.active), #scr-lang:not(.active) {
    display: none !important;
  }

  #scr-phone > .pad, #scr-otp > .pad, #scr-setup > .pad {
    width: 100%;
    max-width: 500px;
    background: rgba(30, 16, 48, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* 3. Right Detail Panel (Split View) */
  #desktop-detail {
    background: var(--shell-bg);
    border-left: 1px solid var(--border);
    position: relative;
    z-index: 10;
  }

  #desktop-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
  }

  #desktop-detail-empty .detail-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.7;
  }

  #desktop-detail-empty .detail-empty-title {
    color: var(--text);
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 8px;
  }

  #desktop-detail-empty .detail-empty-sub {
    font-size: 13.5px;
    color: var(--text-muted);
    max-width: 260px;
    line-height: 1.5;
    margin-bottom: 24px;
  }

  #desktop-detail-empty .detail-empty-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  #desktop-detail-empty .detail-hint-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
  }

  /* When thread is active on desktop, position #scr-thread into the right detail panel */
  body.desktop-thread-active #scr-thread {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    width: var(--detail-w) !important;
    background: var(--bg) !important;
    z-index: 20 !important;
    border-left: 1px solid var(--border);
    left: auto !important;
  }

  body.desktop-thread-active #scr-thread .btn-back {
    display: none;
  }

  /* The detail column's placeholder must give way to the open conversation. */
  body.desktop-thread-active #desktop-detail-empty {
    display: none !important;
  }

  .kbd-hint {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
  }
}

/* ════════════ Mobile Fallback (<900px) ════════════ */
@media (max-width: 899px) {
  #desktop-sidebar {
    display: none !important;
  }
  
  #desktop-detail {
    display: none !important;
  }
  
  #desktop-shell {
    display: block;
    height: 100vh;
    overflow: hidden;
  }
  
  .kbd-hint {
    display: none !important;
  }
}
