/* =========================================================
   CONNECTO — GLOBAL DESIGN SYSTEM
   Mobile First / Responsive / Dark Social UI
   ========================================================= */

:root {
  --bg: #050505;
  --bg-soft: #090909;
  --surface: #0d0d0d;
  --surface-2: #121212;
  --surface-3: #181818;

  --text: #ffffff;
  --text-soft: #e5e5e5;
  --muted: #9b9b9b;

  --border: #282828;
  --border-light: #383838;

  --primary: #ffffff;
  --primary-text: #050505;

  --success: #32d74b;
  --warning: #ffd60a;
  --danger: #ff453a;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow:
    0 10px 35px rgba(0, 0, 0, .35);

  --transition:
    180ms cubic-bezier(.2,.8,.2,1);

  --safe-top:
    env(safe-area-inset-top, 0px);

  --safe-bottom:
    env(safe-area-inset-bottom, 0px);
}


/* =========================================================
   RESET
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0 auto;
  padding:
    calc(14px + var(--safe-top))
    14px
    calc(20px + var(--safe-bottom));

  width: 100%;
  max-width: 760px;
  min-height: 100dvh;

  background:
    radial-gradient(
      circle at top,
      rgba(255,255,255,.035),
      transparent 420px
    ),
    var(--bg);

  color: var(--text);

  font-family:
    Arial,
    "Noto Sans Arabic",
    system-ui,
    -apple-system,
    sans-serif;

  line-height: 1.5;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   TYPOGRAPHY
   ========================================================= */

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--text);
  line-height: 1.25;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(30px, 7vw, 44px);
  font-weight: 800;
  letter-spacing: -.7px;
}

h2 {
  margin-bottom: 14px;
  font-size: 24px;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

p {
  margin-top: 6px;
}

.muted {
  color: var(--muted);
}


/* =========================================================
   UTILITIES
   ========================================================= */

.hidden {
  display: none !important;
}

.status {
  margin: 12px 0;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.uid {
  direction: ltr;
  text-align: left;

  padding: 12px;

  overflow-wrap: anywhere;

  color: var(--text-soft);
  background: var(--surface-2);

  border: 1px solid var(--border);
  border-radius: var(--radius-sm);

  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}


/* =========================================================
   CARDS / BOXES
   ========================================================= */

.box {
  position: relative;

  margin-top: 16px;
  padding: 18px;

  overflow: hidden;

  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.025),
      rgba(255,255,255,0)
    ),
    var(--surface);

  border: 1px solid var(--border);
  border-radius: var(--radius-lg);

  box-shadow: var(--shadow);
}


/* =========================================================
   FORM CONTROLS
   ========================================================= */

input,
select,
textarea {
  width: 100%;

  margin: 6px 0;
  padding: 13px 14px;

  color: var(--text);
  background: var(--surface-2);

  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);

  outline: none;

  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
}

input::placeholder,
textarea::placeholder {
  color: #777;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #777;

  background: #151515;

  box-shadow:
    0 0 0 3px rgba(255,255,255,.07);
}

textarea {
  min-height: 110px;
  resize: vertical;
}


/* =========================================================
   BUTTONS
   ========================================================= */

button {
  width: 100%;

  min-height: 48px;

  margin: 6px 0;
  padding: 12px 16px;

  color: var(--primary-text);
  background: var(--primary);

  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm);

  font-weight: 700;

  cursor: pointer;

  transition:
    transform var(--transition),
    opacity var(--transition),
    background var(--transition),
    box-shadow var(--transition);
}

button:hover {
  background: #e8e8e8;
}

button:active {
  transform: scale(.98);
}

button:focus-visible {
  outline: 3px solid rgba(255,255,255,.25);
  outline-offset: 2px;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}


/* =========================================================
   ACTION GRID
   ========================================================= */

.actions {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 10px;
}


/* =========================================================
   AUTH
   ========================================================= */

#auth-box {
  animation: connectoEnter .25s ease-out;
}

#auth-message {
  min-height: 24px;
}


/* =========================================================
   PROFILE
   ========================================================= */

.profile-row {
  display: flex;
  align-items: center;

  gap: 14px;
}

#profile-photo {
  flex: 0 0 auto;

  width: 88px;
  height: 88px;

  object-fit: cover;

  background: var(--surface-3);

  border: 2px solid var(--border-light);
  border-radius: 50%;
}

#profile-display-name {
  display: block;

  max-width: 100%;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  font-size: 19px;
}


/* =========================================================
   CALL SYSTEM
   ========================================================= */

#call-box,
#incoming-box,
#active-box {
  animation: connectoEnter .22s ease-out;
}

#incoming-box {
  border-color: rgba(50,215,75,.4);

  box-shadow:
    0 0 0 1px rgba(50,215,75,.05),
    var(--shadow);
}

#active-box {
  border-color: #333;
}

#active-status {
  font-size: 17px;
  font-weight: 700;
}

#hangup-btn {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

#hangup-btn:hover {
  background: #e93e36;
}

#accept-btn {
  color: #fff;
  background: var(--success);
  border-color: transparent;
}

#reject-btn {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}


/* =========================================================
   CALL DEBUG
   ========================================================= */

#debug-box {
  margin-top: 12px;
  padding: 13px;

  color: var(--text-soft);
  background: #0a0a0a;

  border: 1px solid var(--border);
  border-radius: var(--radius-sm);

  font-size: 14px;
  line-height: 1.7;
}


/* =========================================================
   VIDEO CALL
   ========================================================= */

#local-wrap,
#remote-wrap {
  margin-top: 18px;
}

#local-video,
#remote-video {
  position: relative;

  width: 100%;
  height: clamp(260px, 62vw, 430px);

  margin-top: 8px;

  overflow: hidden;

  background:
    linear-gradient(
      135deg,
      #111,
      #070707
    );

  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

#local-video video,
#remote-video video {
  width: 100% !important;
  height: 100% !important;

  object-fit: cover !important;
}


/* =========================================================
   MEDIA / POSTS FOUNDATION
   ========================================================= */

.connecto-post {
  margin-top: 14px;
  padding: 14px;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.connecto-media {
  width: 100%;
  max-height: 680px;

  margin-top: 12px;

  object-fit: cover;

  background: #000;

  border-radius: var(--radius-md);
}

.connecto-avatar {
  width: 44px;
  height: 44px;

  object-fit: cover;

  background: var(--surface-3);

  border-radius: 50%;
}


/* =========================================================
   REELS FOUNDATION
   ========================================================= */

.connecto-reel {
  position: relative;

  width: 100%;
  min-height: 70dvh;

  overflow: hidden;

  background: #000;

  border-radius: var(--radius-lg);
}

.connecto-reel video {
  width: 100%;
  height: 100%;

  object-fit: cover;
}


/* =========================================================
   LOADING
   ========================================================= */

.connecto-loading {
  display: inline-block;

  width: 22px;
  height: 22px;

  border: 3px solid #333;
  border-top-color: #fff;
  border-radius: 50%;

  animation: connectoSpin .7s linear infinite;
}


/* =========================================================
   SCROLLBAR
   ========================================================= */

* {
  scrollbar-width: thin;
  scrollbar-color: #444 #0a0a0a;
}

::-webkit-scrollbar {
  width: 7px;
}

::-webkit-scrollbar-track {
  background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 20px;
}


/* =========================================================
   ANIMATIONS
   ========================================================= */

@keyframes connectoEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes connectoSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 520px) {

  body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .box {
    padding: 15px;
    border-radius: 16px;
  }

  .actions {
    gap: 8px;
  }

  #profile-photo {
    width: 76px;
    height: 76px;
  }
}


/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 360px) {

  .actions {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }
}


/* =========================================================
   TABLET / DESKTOP
   ========================================================= */

@media (min-width: 761px) {

  body {
    padding-top: 24px;
    padding-bottom: 32px;
  }

  .box {
    padding: 22px;
  }
  }
