﻿/* Soubor: assets/style.css */
:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --accent: #3b82f6;
  --panel: #111827;
  --panel2: #0b1222;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --primary: #3b82f6;
  --line: #1f2937;
}


* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial;
}

/* ?? Celkové rozložení */
#layout {
  display: grid;
  grid-template-columns: 320px 1fr 360px;
  grid-template-rows: 100%;
  height: 100vh;
}



#search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a1222;
  color: var(--text);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
}

.list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.list li:hover {
  background: #0f1931;
}

.list .name {
  font-weight: 600;
}

.list .sub {
  font-size: 12px;
  color: var(--muted);
}

/* ?? Chat panel */
#chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--panel);
  height: 100%;
}

#chatHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

#chatHeader .title {
  font-weight: 700;
}

#chatHeader .subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.actions .btn {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #0a1222;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.actions .btn:hover {
  background: #0f1931;
}

/* ?? Zprávy */
#messages {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.msg {
  max-width: 70%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.msg.in {
  background: #0d1a2e;
  align-self: flex-start;
}

.msg.out {
  background: #0a1222;
  align-self: flex-end;
}

.msg .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ?? Composer (pole pro psaní zprávy) */
#composer {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 10px;
  position: sticky;
  z-index: 10;
}

#sendForm {
  display: flex;
  gap: 10px;
}



/* ?? Tlačítka */
.btn {
  background: #0a1222;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  border: 0;
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

/* ?? Detail panel */
#detail {
  background: var(--panel2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.detail-header {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.detail-form input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a1222;
  color: var(--text);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
/* ?? Detail klienta – přidán vnitřní scroll */
#detail {
  background: var(--panel2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* zabrání přetékání celé sekce */
}

.detail-form {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto; /* ?? přidán posuvník uvnitř */
  max-height: calc(100vh - 60px); /* přizpůsobí výšku okna */
}

.detail-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.detail-form input,
.detail-form select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a1222;
  color: var(--text);
}
/* ?? Nové vylepšení stylu chatu */

/* Hladký scroll a lepší kontrast */
#messages {
  scroll-behavior: smooth;
  padding-bottom: 60px; /* rezerva pro composer */
}

/* Příchozí zprávy – světlejší text */
.msg.in {
  background: #1e293b;
  color: #e2e8f0;
  align-self: flex-start;
  border-top-left-radius: 4px;
  border-top-right-radius: 16px;
}

/* Odchozí zprávy – modré bubliny */
.msg.out {
  background: #2563eb;
  color: #ffffff;
  align-self: flex-end;
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
}

/* Čas a směr zprávy */
.msg .meta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
  text-align: right;
}

/* Oddělení chatu od composeru */
#composer {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 10px;
  position: sticky;
  bottom: 0;
  z-index: 10;
}
.unknown-banner {
  background: #fffbe6;
  border: 1px solid #f1c232;
  color: #665c00;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 6px;
  font-size: 14px;
}
.unknown-banner button {
  margin-left: 10px;
  background: #ffd966;
  border: none;
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
}
.unknown-banner button:hover {
  background: #f1c232;
}
.section-title {
  font-size: 0.9rem;
  color: #aaa;
  margin: 10px 0 4px 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.list li {
  cursor: pointer;
  padding: 8px 10px;
  border-bottom: 1px solid #1a1a1a;
}
.list li:hover {
  background: #202020;
}
.top-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: flex-start;
  align-items: center;
}

.banner {
  background: #fff4cc;
  color: #333;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

/* ?? Horní řádek s tlačítky */
.top-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.top-buttons .btn {
  padding: 6px 12px;
  font-size: 0.9rem;
}

/* ?? Styl pro „Přidat mezi klienty“ */
.btn.primary.small {
  background-color: #4caf50;
  color: white;
  border: none;
  transition: background-color 0.2s ease;
}
.btn.primary.small:hover {
  background-color: #43a047;
}

/* ?? Styl pro banner */
.banner {
  background: #fff8dc;
  border-left: 4px solid #ffcc00;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #333;
}

.banner::before {
  content: "??";
  font-size: 1.1rem;
}


.chat-input-area {
    background: #0d1117;
    padding: 10px;
    border-top: 1px solid #1f2937;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chatMessage {
    flex: 1;
    min-height: 50px;
    max-height: 150px;
    resize: vertical;
    background: #161b22;
    color: #fff;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 8px;
}

#sendBtn {
    background: #0078ff;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

#attachmentPreview {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 8px;
    gap: 6px;
}

.attachment-preview-item {
    background: #1f2937;
    padding: 5px 10px;
    border-radius: 5px;
    color: #ccc;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.attachment-preview-item i {
    cursor: pointer;
    color: #ff6b6b;
}
/* === Rozšířený composer === */
#composer {
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: 10px;
}

#composer form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
#msgInput {
  width: 100%;
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #11161d;
  color: #fff;
  outline: none;
  font-size: 15px;
  line-height: 1.4;

  /* ✳️ Dynamická výška */
  resize: none;
  overflow-y: hidden;
  min-height: 40px;
  max-height: 200px;
  transition: height 0.1s ease;
}




/* Náhled příloh */
#attachmentPreview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.attachment-item {
    background: #1f2937;
    padding: 6px 10px;
    border-radius: 6px;
    color: #ccc;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.attachment-item i {
    color: #ff7070;
    cursor: pointer;
    font-style: normal;
    font-weight: bold;
}
.img-wrap img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  display: block;
  margin-bottom: 5px;
}

.pdf-wrap iframe {
  width: 220px;
  height: 280px;
  border: none;
  border-radius: 8px;
  background: #fff;
  display: block;
  margin-bottom: 6px;
}

.file-link {
  color: #c9d1d9;
  text-decoration: none;
  display: inline-block;
  word-break: break-word;
}

.file-link:hover {
  text-decoration: underline;
}
#clientsList {
  scrollbar-width: thin;
  scrollbar-color: #888 #f0f0f0;
}


.bottom-buttons {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

/* === Styl souborového seznamu === */
.file-item a {
  color: #ddd;                /* světle šedá místo modré */
  text-decoration: none;
  flex: 1;
  overflow-wrap: anywhere;
}

.file-item a:hover {
  color: #fff;
  text-decoration: underline;
}

.file-item .size {
  color: #888;
  font-size: 0.85em;
}

/* === Popup s náhledem === */
.file-preview-popup {
  position: fixed;
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid #444;
  padding: 10px;
  border-radius: 10px;
  z-index: 9999;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview-popup img,
.file-preview-popup iframe {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 6px;
  background: #111;
}
.hidden {
  display: none !important;
}
.hidden { display: none !important; }
.file-preview-popup.hidden {
  display: none;
}

.file-preview-popup .close-btn {
  position: absolute;
  top: 10px;
  right: 20px;
  background: #333;
  color: #fff;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
}
/* ?? Panely */
#sidebar, #chat, #detail {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ?? Sidebar */
#sidebar {
  background: var(--panel2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header h2 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

/* ✳️ Dynamické přizpůsobení sekcí */
#sidebar .section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: none;
}

/* === Neznámé kontakty === */
#unknownList {
  background: #0f141a;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 5px;
  padding: 6px 0;
  overflow-y: visible; /* ✳️ povoleno přirozené roztažení */
  transition: all 0.3s ease;
  max-height: fit-content; /* ✳️ výška podle obsahu */
  flex-shrink: 0; /* ✳️ zabrání zmenšování */
}

#unknownList.empty {
  max-height: 40px; /* ✳️ prázdný seznam velmi malý */
  overflow: hidden;
  opacity: 0.7;
}

#unknownList .unknown-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  transition: background 0.2s ease;
}

#unknownList .unknown-entry:hover {
  background: rgba(255,255,255,0.08);
}

#unknownList .btn.small.danger {
  background: #c0392b;
  color: #fff;
  border: none;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}

#unknownList .btn.small.danger:hover {
  background: #e74c3c;
}

/* === Klienti === */
#clientsList {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0 10px 10px 10px;
  list-style: none;
  max-height: calc(100vh - 280px); /* ✳️ klienti využijí zbytek místa */
}

#unknownList li,
#clientsList li {
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

#unknownList li:hover,
#clientsList li:hover {
  background: rgba(255,255,255,0.05);
}

.list li.active {
  background: rgba(59,130,246,0.25);
  border-left: 3px solid #3b82f6;
}

.section {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.section h4 {
  margin: 6px 12px;
  font-size: 14px;
  color: var(--muted);
}
/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.tab-btn:hover {
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab-content {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-content.active {
  display: block;
}

/* --- Table layout --- */
.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table td {
  padding: 5px 8px;
  vertical-align: middle;
}

.detail-table td:first-child {
  width: 40%;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
}

.detail-table input,
.detail-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a1222;   /* nahrazuje var(--bg-input) */
  color: var(--text);    /* světlé písmo */
}

/* options uvnitř selectu */
.detail-table select option {
  background: #0a1222;
  color: var(--text);
}


/* --- Animace --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* WhatsApp zprávy – decentně zelené */
.msg-whatsapp .body {
  background: #075e5430;
  border-left: 4px solid #25D366;
}

/* Messenger zprávy – decentně modré */
.msg-messenger .body {
  background: #006aff20;
  border-left: 4px solid #0084ff;
}

/* Ikona v pravém dolním rohu bubliny */
.msg-whatsapp .meta::after {
  content: "📱";
  margin-left: 4px;
  opacity: 0.7;
}

.msg-messenger .meta::after {
  content: "💬";
  margin-left: 4px;
  opacity: 0.7;
}

#messages .body {
  white-space: pre-line; /* zachová odstavce a nové řádky */
  line-height: 1.5;
  word-wrap: break-word;
}
/* Drag & drop area styling */
#composer.drop-active {
  outline: 2px dashed rgba(99,102,241,0.6);
  background: rgba(99,102,241,0.04);
  transition: background .12s ease;
}

#composer .drop-hint {
  display: none;
  font-size: 13px;
  color: #9aa4b2;
  text-align: center;
  padding: 6px 8px;
  border-radius: 6px;
}

#composer.drop-active .drop-hint {
  display: block;
  margin-bottom: 6px;
}
/* === Náhled příloh (WhatsApp styl) === */
.attachment-item {
  display: flex;
  align-items: center;
  background: #1e293b;
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  gap: 10px;
  color: #e2e8f0;
}

.attachment-item .thumb img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #2c3e50;
}

.attachment-item .file-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

.attachment-item .file-size {
  font-size: 11px;
  color: #94a3b8;
}

.attachment-item i {
  cursor: pointer;
  font-style: normal;
  color: #f87171;
  font-weight: bold;
  font-size: 18px;
}

.attachment-item i:hover {
  color: #ef4444;
}

.attachment-item .file-icon {
  font-size: 20px;
  opacity: 0.7;
}
.file-link {
  display: inline-block;
  color: #c9d1d9;
  text-decoration: none;
  word-break: break-word;
  margin-right: 6px;
}

.file-link:hover {
  color: #58a6ff;
  text-decoration: underline;
}

.save-btn {
  background: #222;
  border: 1px solid #444;
  color: #ccc;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.save-btn:hover {
  background: #333;
  color: #fff;
}
.file-link[draggable="true"] {
  cursor: grab;
}

.file-link[draggable="true"]:active {
  cursor: grabbing;
}
#clientFiles.drop-active {
  outline: 3px dashed #3a9dfd;
  background: rgba(58,157,253,0.1);
  border-radius: 10px;
  transition: background 0.2s ease;
}
/* ✳️ Doplněk pro hromadné zprávy */
    #bulkMessagePanel {
      background: #11161d;
      border-top: 1px solid var(--line);
      padding: 10px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    #bulkMessagePanel.hidden { display: none; }
    #bulkMessageText {
      width: 100%;
      height: 80px;
      border-radius: 10px;
      background: #1a2028;
      color: #fff;
      padding: 8px;
      border: 1px solid var(--line);
    }
    .selectContact {
      margin-right: 6px;
      accent-color: #00cc66;
    }
    .btn-save {
  background: #007bff;
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  border: none;
  cursor: pointer;
}
.btn-save:hover {
  background: #005fcc;
}
.btn-ai {
  background: linear-gradient(90deg, #00a884, #008c6e);
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  text-decoration: none;
  margin-left: 6px;
}
.btn-ai:hover {
  background: linear-gradient(90deg, #00c693, #00a884);
}
#chatgpt_link {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  background: #222;
  color: #9cf;
}
#chatgpt_link.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.copy-btn {
  margin-left: 10px;
  padding: 4px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #1e293b;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.8;
  transition: all 0.2s;
}

.copy-btn:hover {
  opacity: 1;
  background: #334155;
  border-color: #777;
}

.copy-wrapper {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
/* === 🧠 SHRUTÍ – nové rozložení === */
.summary-box-wide {
  width: 100%;
  background: #1e1e1e;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 12px;
  color: #eee;
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.summary-text {
  white-space: pre-wrap;
  line-height: 1.5;
  background: #262626;
  border-radius: 8px;
  padding: 10px;
  color: #ddd;
}

#summaryDetailView {
  display: none;
  background: #111;
  color: #eee;
  padding: 20px;
  height: calc(100vh - 100px);
  overflow-y: auto;
}

#summaryDetailView.active {
  display: block;
}

#summaryDetailView button {
  margin-bottom: 16px;
}

.summary-detail-full {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 100px);
  color: #ddd;
}

.summary-detail-full .summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
/* ✳️ Fix viditelnosti detailního shrnutí */
#summaryDetailView {
  position: relative;
  z-index: 9999; /* přenese dopředu */
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: #ddd;
  background: #0b0f1a;
  width: 100%;
  height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px;
}

#summaryDetailView .summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #141a25;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
}

#summaryDetailText {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 15px;
  padding: 10px 14px;
}
.summary-box {
  background: #101522;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: #ddd;
  line-height: 1.5;
  margin-top: 6px;
}

.summary-box hr {
  border: none;
  border-top: 1px solid #223;
  margin: 8px 0;
}

.summary-box strong {
  color: #8afc8a;
}

#fileHoverPreview {
  box-shadow: 0 2px 15px rgba(0,0,0,0.4);
  transition: opacity 0.2s ease-in-out;
  opacity: 0.95;
}
#fileHoverPreview img {
  transition: transform 0.1s ease-in-out, opacity 0.2s;
}
#fileHoverPreview img:hover {
  transform: scale(1.02);
  opacity: 0.98;
}
.btn-copy-img:hover {
  filter: brightness(1.2);
}
.file-item.copied-ok {
  background: rgba(0,200,0,0.08);
  transition: background 0.3s ease;
}
.btn-copy-file:hover {
  filter: brightness(1.25);
}
#fileHoverPreview img {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from {opacity:0; transform:scale(0.97);}
  to {opacity:1; transform:scale(1);}
}
