/* /frontend/styles.css */
:root{
  --bg:#0b0f14;
  --card:#101826;
  --card2:#0f1723;
  --text:#e8eef7;
  --muted:#8aa0b8;
  --border:rgba(255,255,255,.08);
  --btn:#2b6cb0;
  --btn2:#1f2937;
  --danger:#dc2626;
  --ok:#16a34a;
  --warn:#f59e0b;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
}

*{ box-sizing:border-box; }
html,body{ height:100%; width:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1000px 500px at 20% 0%, rgba(43,108,176,.25), transparent),
              radial-gradient(900px 500px at 80% 10%, rgba(16,185,129,.12), transparent),
              var(--bg);
  color:var(--text);
  overflow-x: hidden;
}

code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size: .95em;
}

.app{
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 18px;
  min-height: 100%;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 14px 16px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.brand{ display:flex; align-items:center; gap:12px; }
.dot{
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(245,158,11,.15);
}
.title{ font-weight: 700; letter-spacing:.2px; }
.subtitle{ color: var(--muted); font-size: .92rem; }

.top-actions{ display:flex; gap:10px; flex-wrap: wrap; }

.main{
  flex:1;
  width: 100%;
  display:grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}

#chatCard{
  width: 100%;
  min-width: 0;
}

.card{
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.card h2{ margin: 0 0 14px; }

.grid{ display:grid; gap: 12px; }
.field{ display:flex; flex-direction:column; gap: 6px; }
.field span{ color: var(--muted); font-size: .9rem; }

input[type="text"], input[type="username"], input[type="password"]{
  width: 100%;
  border-radius: 12px;
  padding: 12px 12px;
  border:1px solid var(--border);
  background: rgba(9,14,20,.55);
  color: var(--text);
  outline:none;
}
input:focus{
  border-color: rgba(43,108,176,.6);
  box-shadow: 0 0 0 4px rgba(43,108,176,.15);
}

.row{ display:flex; gap:10px; margin-top: 12px; flex-wrap: wrap; }

.btn{
  appearance:none;
  border:1px solid rgba(255,255,255,.10);
  background: var(--btn);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 650;
  white-space: nowrap;
}
.btn:hover{ filter: brightness(1.07); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.6; cursor:not-allowed; transform:none; }

.btn-secondary{ background: var(--btn2); }
.btn-ghost{ background: transparent; border-color: rgba(255,255,255,.10); }

.hint{
  margin-top: 12px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.45;
}

.chat{ display:flex; flex-direction:column; gap:12px; }
.chat-header{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  flex-wrap: wrap;
}
.chat-header h2{ margin:0; }
.chat-tools{ display:flex; gap:10px; align-items:center; flex-wrap: wrap; }

.file input{ display:none; }

.messages{
  width: 100%;
  min-width: 0;
  border:1px solid var(--border);
  background: rgba(9,14,20,.55);
  border-radius: 14px;
  padding: 12px;
  height: 520px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.msg{
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 10px 12px;
  overflow: hidden;
}
.msg .meta{
  display:flex;
  gap:10px;
  align-items: baseline;
  justify-content:space-between;
  color: var(--muted);
  font-size: .86rem;
  margin-bottom: 6px;
}
.msg .meta .who{ color: var(--text); font-weight: 650; }
.msg .body{ white-space: pre-wrap; line-height: 1.4; }
.msg a{ color: #93c5fd; text-decoration: none; }
.msg a:hover{ text-decoration: underline; }

.msg .imgwrap{
  max-width: min(520px, 100%);
}
.msg img.chatimg{
  display:block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
}

.msg .filemeta{
  margin-top: 6px;
  color: var(--muted);
  font-size: .86rem;
}

.composer{
  display:flex;
  gap: 10px;
  width: 100%;
}
.composer input{ flex:1; min-width: 0; }

.log{
  margin:0;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.35);
  border: 1px dashed rgba(255,255,255,.12);
  color: rgba(232,238,247,.85);
  max-height: 160px;
  overflow:auto;
  font-size: .86rem;
}

.footer{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding: 12px 14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: 16px;
  color: var(--muted);
  flex-wrap: wrap;
}
.muted{ color: var(--muted); }

/* ===== MOBILE / RESPONSIVE ===== */

/* tablets */
@media (max-width: 980px){
  .main{ grid-template-columns: 1fr; }
  .messages{ height: 55vh; }
}

/* phones */
@media (max-width: 560px){
  .app{ padding: 12px; }

  .topbar{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .top-actions{
    width: 100%;
    justify-content: flex-start;
  }

  .card{ padding: 14px; }

  .chat-header{
    flex-direction: column;
    align-items: flex-start;
  }

  .messages{
    height: 58vh;
    padding: 10px;
  }

  .composer{
    flex-direction: column;
    gap: 8px;
  }

  .composer input{
    width: 100%;
  }

  .btn{
    width: 100%;
    text-align: center;
  }

  .msg .meta{
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .msg .imgwrap{
    max-width: 100%;
  }

  .msg img.chatimg{
    max-height: 220px;
  }

  .footer{
    flex-direction: column;
    align-items: flex-start;
  }
}