/* ==========================================================================
   TOONEXY GLOBAL CSS — Zajednički stilovi za sve stranice
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, sans-serif;
  background: #eeeeee;
  color: #111111;
}

body { overflow-x: hidden; }

/* Gornja traka (Top Bar) */
.topBar {
  min-height: 38px;
  height: auto;
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  border-bottom: 1px solid #c8c8c8;
  background: #f7f7f7;
  font-size: 14px;
}

.channelLabel { font-weight: 700; }

#loginRegisterBtn, #toonexyBtn, #myProfileBtn, #reloadChatBtn, #exportStripBtn, #shareChatBtn, #toonvitationBtn {
  display: none;
  width: auto;
  min-height: 31px;
  margin: 0;
  padding: 5px 12px;
  border: 1px solid #aaaaaa;
  border-radius: 4px;
  background: #ffffff;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}

#loginRegisterBtn { margin-left: auto; }
#toonexyBtn { display: inline-block !important; margin-left: auto; }
#loginRegisterBtn[style*="inline-block"] + #toonexyBtn { margin-left: 0; }

#loginRegisterBtn:hover, #toonexyBtn:hover, #myProfileBtn:hover, #reloadChatBtn:hover, #exportStripBtn:hover, #shareChatBtn:hover, #toonvitationBtn:hover {
  background: #e9e9e9;
}

#shareStatus { color: #555555; white-space: nowrap; font-size: 12px; }

/* Shared ToonExy app layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  min-height: calc(100vh - 38px);
  transition: grid-template-columns 0.2s ease;
}

.layout.menuCollapsed { grid-template-columns: minmax(0, 1fr) 42px; }

/* Sakrivanje teksta i bojenje cijele kockice u crveno samo u desktop verziji kada je meni skupljen */
.layout.menuCollapsed #nextImageCounter {
  font-size: 0;
  color: transparent;
  padding: 6px 2px;
  overflow: hidden;
}

.layout.menuCollapsed #nextImageCounter.counting {
  background-color: #d71920;
  border-color: #a50000;
}

.mainArea {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
}

.pageHidden { display: none !important; }

#toonexyChatShell { width: 100%; }

#timelineArea { display: none; width: 100%; }
body.chatConnected #timelineArea { display: block; }

#stripTimeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: center;
  align-items: start;
  gap: 12px;
  width: 100%;
}

.stripPanel {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #222222;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

.stripPanel img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 12;
  object-fit: contain;
  background: #dddddd;
}

#strip { display: none; width: 800px; height: 600px; aspect-ratio: 16 / 12; }

#chatBar {
  display: none;
  width: min(100%, 820px);
  gap: 6px;
  align-items: center;
  margin-top: 12px;
}

#chatInput { flex: 1; margin-bottom: 0; }
#sendBtn { width: 90px; margin-bottom: 0; }

.connectPanel, .sidePanel {
  padding: 12px;
  background: #f4f4f4;
  border-left: 1px solid #c8c8c8;
}

.connectPanel {
  width: 250px;
  position: fixed;
  right: 0;
  top: 38px;
  bottom: 0;
  z-index: 5;
  overflow-y: auto;
}

.sidePanel {
  display: none;
  min-height: calc(100vh - 38px);
  align-self: start;
  position: sticky;
  top: 38px;
  max-height: calc(100vh - 38px);
  overflow-y: auto;
  transition: padding 0.2s ease;
}

body.chatConnected .sidePanel { display: block; }
.sidePanel.collapsed { padding: 6px 4px; overflow: hidden; }

.sidePanel.collapsed #memberList,
.sidePanel.collapsed #avatarMoodPanel,
.sidePanel.collapsed .filterSection {
  display: none !important;
  visibility: hidden;
  height: 0;
  max-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

#menuToggle {
  width: 100%;
  min-height: 30px;
  margin: 0 0 10px;
  padding: 3px;
  font-size: 18px;
  line-height: 20px;
}

label { display: block; margin: 0 0 5px; font-size: 13px; }

input, select, button {
  width: 100%;
  min-height: 31px;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid #aaaaaa;
  border-radius: 4px;
  background: #ffffff;
  font: inherit;
}

button { cursor: pointer; }
button:hover { background: #e9e9e9; }

/* Tranzicije i stilovi za avatare i preview slike */
#bigAvatar, #connectedBigAvatar, #inviteAvatarPreview, .backgroundPreviewClass {
  display: block;
  object-fit: contain;
  background: #eeeeee;
  transition: opacity 0.3s ease-in-out;
}

#bigAvatar, #connectedBigAvatar, #inviteAvatarPreview {
  width: 180px;
  height: 205px;
  margin: 8px auto 12px;
}

#bgFileSelect:disabled { color: #777777; background: #e9e9e9; }
#avatarMoodPanel { display: none; }

#nextImageCounter {
  min-height: 32px;
  margin: 0 0 10px;
  padding: 6px 8px;
  border: 1px solid #777777;
  border-radius: 4px;
  background: #ffffff;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
  color: #111111;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Standardno crvenilo okvira/teksta kada je meni proširen */
#nextImageCounter.counting { 
  color: #d00000; 
  border-color: #d00000; 
}

#memberList { margin-top: 8px; }

.memberRow {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  padding: 2px 0;
  cursor: pointer;
}

.memberRowSelf { font-weight: 700; }

.memberBubble {
  width: 11px;
  height: 11px;
  border: 1px solid #777777;
  border-radius: 50%;
  background: #ffffd8;
  flex: 0 0 auto;
}

.memberNick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.memberNickSelf {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.nicknameToggle {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nicknameToggle.active { background: #d71920; border-color: #a50000; color: #ffffff; }

.filterSection {
  display: none;
  margin: 10px 0;
  padding: 8px;
  border: 1px solid #aaaaaa;
  border-radius: 4px;
  background: #ffffff;
}

.filterSectionTitle {
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #dddddd;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, background-color 0.2s;
}

.filterSectionTitle:hover { color: #d71920; background-color: #fafafa; }
.filterSection label { margin-bottom: 2px; font-size: 12px; }
.filterSection input[type="range"] { min-height: 24px; margin-bottom: 6px; }

.sideBackgroundPreview {
  display: flex;
  width: 100%;
  margin: 6px 0 2px;
  justify-content: center;
  align-items: center;
}

.backgroundPreviewClass {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border: 1px solid #777777;
  border-radius: 4px;
}

.connection-slot-notice {
  margin: 0 0 8px;
  padding: 7px 8px;
  border: 1px solid #b42318;
  border-radius: 4px;
  background: #fff1f0;
  color: #b42318;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.connection-slot-notice[hidden] { display: none; }

/* Toonvitation Modal */
.toonvitation-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.toonvitation-modal.open { display: flex; }

.toonvitation-content {
  background: #f7f7f7;
  border: 3px solid #171717;
  box-shadow: 6px 6px 0 #171717;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  border-radius: 6px;
  box-sizing: border-box;
}

.toonvitation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 2px solid #ccc;
  padding-bottom: 8px;
}

.toonvitation-header h3 { margin: 0; font-size: 18px; font-weight: 900; }

.toonvitation-close {
  background: transparent;
  border: none;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  width: auto;
  min-height: auto;
  margin: 0;
  padding: 0 5px;
}

.toonvitation-error {
  color: #b42318;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 8px;
  min-height: 16px;
}

/* Comic Connect button */
#connectBtn {
  min-height: 40px;
  margin-top: 14px;
  padding: 8px 14px;
  border: 2px solid #171717;
  border-radius: 0;
  color: #ffffff;
  background: #e5322d;
  box-shadow: 3px 3px 0 #171717;
  font-size: 17px;
  font-weight: 950;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

#connectBtn:hover:not(:disabled) {
  background: #b91b20;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #171717;
}

#connectBtn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }

#connectBtn:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
  box-shadow: 2px 2px 0 #777777;
}

#connectBtn:focus-visible { outline: 3px solid #3d8ee8; outline-offset: 4px; }

/* Responsive Media Queries */
@media (max-width: 1300px) {
  #stripTimeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .layout, .layout.menuCollapsed { display: block; }
  .connectPanel {
    width: 100%;
    position: static;
    border-left: 0;
    border-bottom: 1px solid #c8c8c8;
  }
  .sidePanel {
    min-height: auto;
    max-height: none;
    position: static;
    border-left: 0;
    border-top: 1px solid #c8c8c8;
  }
  .sidePanel.collapsed { min-height: 0; height: auto; padding: 6px 8px; }
  
  .layout.menuCollapsed #nextImageCounter {
    font-size: 14px;
    color: #111111;
    padding: 6px 8px;
  }

  /* Poništavamo crvenu pozadinu na mobilnom da ostane standardno ponašanje ako zatreba */
  .layout.menuCollapsed #nextImageCounter.counting {
    background-color: #ffffff;
    border-color: #d00000;
    color: #d00000;
  }

  #stripTimeline { grid-template-columns: 1fr; }
  .topBar {
    height: auto;
    min-height: 38px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 6px 8px;
  }
  .channelLabel {
    width: 100%;
    text-align: center;
    font-size: 13px;
  }
  #loginRegisterBtn, #toonexyBtn, #myProfileBtn, #reloadChatBtn, #exportStripBtn, #shareChatBtn, #toonvitationBtn {
    flex: 1 1 calc(50% - 6px);
    max-width: 100%;
    margin: 0 !important;
    text-align: center;
    padding: 5px 8px;
    font-size: 12px;
  }
  #loginRegisterBtn { margin-left: auto; }
  #toonexyBtn { margin-left: auto; }
  #loginRegisterBtn[style*="inline-block"] + #toonexyBtn { margin-left: 0; }
  #shareStatus {
    width: 100%;
    text-align: center;
    display: block;
  }
  #shareStatus:empty { display: none; }
}

/* Automatsko sakrivanje statičnih panela i prikaz chata kada se konektuješ */
body.chatConnected #staticPageContent,
body.chatConnected #welcomePanel,
body.chatConnected .toonexyWelcome,
body.chatConnected .toonexyDocs,
body.chatConnected .toonexyFaq,
body.chatConnected .toonexyPolicy {
  display: none !important;
}

body.chatConnected #timelineArea {
  display: block !important;
}

body.chatConnected #chatBar {
  display: flex !important;
}