/* ===============================================
   Layout & Structural Styles
   Extracted from test_chat.html
=============================================== */

/* ===============================================
   CSS Custom Properties (Design Tokens)
=============================================== */

:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #161616;
  --bg-card: #1c1c1c;
  --bg-input: #222222;
  --bg-hover: #2a2a2a;
  --border: #2a2a2a;
  --border-light: #333;
  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;
  --accent: #ff653e;
  --accent-hover: #d44a20;
  --accent-glow: rgba(232, 86, 42, 0.15);
  --active: #7f7f7f;
  --blue: #3b9edf;
  --blue-hover: #2d8acb;
  --blue-glow: rgba(59, 158, 223, 0.15);
  --green: #34d399;
  --green-bg: #0d2818;
  --green-border: #166534;
  --yellow: #fbbf24;
  --red: #ef4444;
  --red-bg: #2d1010;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

/* ===============================================
   Reset
=============================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===============================================
   Body
=============================================== */

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===============================================
   Content Protection (Channel Media)
=============================================== */

.channel-post .post-media img,
.channel-post .post-media video {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: auto;
}
.channel-post .post-media {
  position: relative;
}
/* Transparent overlay -- does not block clicks but complicates inspection */
.channel-post .post-media::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 1;
  pointer-events: none;
}
/* Blur on focus loss (anti-screenshot) */
body.blurred .channel-post .post-media img,
body.blurred .channel-post .post-media video {
  filter: blur(20px);
  transition: filter 0.3s ease;
}

/* ===============================================
   Header
=============================================== */

.header {
  background: var(--bg-secondary);
  padding: 14px 24px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-primary) url(../../common/img/icon_34_34.png) no-repeat
    center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  box-shadow: 0 0 20px var(--accent-glow);
}
.header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.header-title span {
  color: var(--accent);
}
.header .status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header .status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.header .status.connected .dot {
  background: var(--blue);
  box-shadow: 0 0 6px var(--blue);
}
.header .status.connected {
  color: var(--blue);
}
.header .status.connecting .dot {
  background: var(--yellow);
  animation: statusPulse 1s ease-in-out infinite;
}
.header .status.connecting {
  color: var(--yellow);
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ===============================================
   Section Tabs (Chat / Channel)
=============================================== */

.section-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.section-tab {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.section-tab svg { flex-shrink: 0; }
.section-tab:hover {
  color: var(--text-primary);
}
.section-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.section-tab.has-unread::after {
  content: "";
  position: absolute;
  top: 8px;
  right: calc(50% - 34px);
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--red);
}

/* ===============================================
   App Container
=============================================== */

.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-container.hidden {
  display: none;
}

/* Section transition */
@keyframes sectionFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.section-animate-in {
  animation: sectionFadeIn 0.2s ease-out;
}

/* ===============================================
   Loading Bar
=============================================== */

.loading-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-secondary, #1e1e1e);
  z-index: 100;
  overflow: hidden;
}
.loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: var(--accent, #3b82f6);
  animation: loadSlide 1s ease-in-out infinite;
}
@keyframes loadSlide {
  0% {
    left: -40%;
  }
  100% {
    left: 100%;
  }
}
#chatSection {
  position: relative;
}
.channel-container {
  position: relative;
}

/* ===============================================
   Responsive (max-width: 600px)
=============================================== */

@media (max-width: 600px) {
  .header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .auth-container {
    padding: 28px 20px;
  }
  .chat {
    padding: 16px;
  }
  .input-area {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .input-area button {
    padding: 12px 16px;
  }
  .main-menu {
    padding: 10px 16px;
  }
  .message {
    max-width: 88%;
  }
  .payment-container {
    padding: 16px;
  }
  .tariff-card {
    padding: 16px;
  }
  .plan-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .plan-row .plan-pay-btn {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }
  .payment-modal {
    padding: 28px 20px;
    margin: 0 16px;
  }
}

/* ===============================================
   Narrow phones (≤ 390px — iPhone SE, mini, etc.)
=============================================== */
@media (max-width: 390px) {
  .input-area {
    padding: 10px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    gap: 6px;
  }
  .input-area input {
    padding: 10px 12px;
    font-size: 13px;
  }
  .input-area button {
    padding: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .input-area .attach-btn {
    padding: 6px 8px;
  }
  .upload-preview-strip {
    padding: 8px 10px;
  }
}
