/* ============================================================
   Components CSS — non-critical styles for below-the-fold UI
   Merged from: chat.css, visitor_counter.css, microblog-slider.css
   Loaded async via media="print" onload="this.media='all'"
   ============================================================ */

/* ──────────────────────────────────────────────────────────────
   Support Chat Widget
   Colors: accent #FF6600, magenta rgba(214,19,126,0.829),
          dark #000, background #C0C0C0
   Font:   Helvetica, Arial, sans-serif
   ────────────────────────────────────────────────────────────── */

/* ----- Widget container ----- */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Helvetica', 'Arial', sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* ----- Toggle button ----- */
.chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(214, 19, 126, 0.829);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.chat-toggle:active {
    transform: scale(0.96);
}

/* Badge for unread messages */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #FF6600;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ----- Chat window ----- */
.chat-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 520px;
    border-radius: 15px;
    background: #1a1a1a;
    color: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* ----- Header ----- */
.chat-header {
    background: #000;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 15px 15px 0 0;
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}

.chat-new-top-btn {
    background: none;
    border: 1px solid #555;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}

.chat-new-top-btn:hover {
    color: #FF6600;
    border-color: #FF6600;
}

.chat-last-top-btn {
    background: none;
    border: 1px solid #555;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}

.chat-last-top-btn:hover {
    color: #4CAF50;
    border-color: #4CAF50;
}

.chat-last-top-btn.hidden,
.chat-new-top-btn.hidden {
    display: none !important;
}

.chat-close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.chat-close-btn:hover {
    color: #fff;
}

/* ----- Info form ----- */
.chat-info-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.chat-info-intro {
    font-size: 13px;
    color: #ccc;
    margin: 0 0 4px 0;
}

.chat-input,
.chat-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #2a2a2a;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.chat-input::placeholder {
    color: #888;
}

.chat-input:focus,
.chat-select:focus {
    outline: none;
    border-color: #FF6600;
}

.chat-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

/* Honeypot — invisible to humans */
.chat-honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    pointer-events: none;
}

/* Remember me checkbox */
.chat-remember-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
}

.chat-remember-cb {
    accent-color: #FF6600;
}

/* Buttons */
.chat-btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, opacity 0.2s;
}

.chat-btn-primary {
    width: 100%;
    padding: 10px;
    background: #FF6600;
    color: #fff;
}

.chat-btn-primary:hover {
    background: #e65c00;
}

.chat-btn-send {
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(214, 19, 126, 0.829);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-btn-send:hover {
    opacity: 0.85;
}

/* ----- Messages area ----- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 340px;
}

.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    word-wrap: break-word;
    position: relative;
}

.chat-msg-in {
    align-self: flex-start;
    background: #333;
    border-bottom-left-radius: 4px;
}

.chat-msg-out {
    align-self: flex-end;
    background: rgba(214, 19, 126, 0.5);
    border-bottom-right-radius: 4px;
}

.chat-msg-source {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.chat-msg-time {
    font-size: 10px;
    color: #777;
    margin-top: 2px;
    text-align: right;
}

/* ----- Input area ----- */
.chat-input-area {
    padding: 10px 12px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* ----- Image upload button ----- */
.chat-btn-image {
    width: 36px;
    height: 36px;
    padding: 0;
    background: none;
    border: 1px solid #555;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s;
}

.chat-btn-image:hover {
    color: #FF6600;
    border-color: #FF6600;
}

/* ----- Image preview (above input) ----- */
.chat-image-preview {
    position: relative;
    padding: 6px 8px;
    background: #222;
    border-top: 1px solid #333;
}

.chat-image-preview img {
    max-height: 60px;
    max-width: 100px;
    border-radius: 4px;
    object-fit: cover;
}

.chat-remove-image {
    position: absolute;
    top: 2px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ----- Image in chat messages ----- */
.chat-msg-image {
    margin-bottom: 4px;
}

.chat-msg-image img {
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

.chat-msg-image a {
    display: inline-block;
}

.chat-msg-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #2a2a2a;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    overflow: hidden;
    min-height: 36px;
    max-height: 120px;
    line-height: 1.4;
    box-sizing: border-box;
}

.chat-msg-input::placeholder {
    color: #888;
}

.chat-msg-input:focus {
    outline: none;
    border-color: #FF6600;
}

/* ----- Session ended ----- */
.chat-ended {
    padding: 20px 16px;
    text-align: center;
}

.chat-ended p {
    color: #aaa;
    font-size: 13px;
    margin: 0 0 12px 0;
}

.chat-ended-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.chat-btn-secondary {
    padding: 8px 16px;
    background: #333;
    color: #ccc;
    flex: 1;
}

.chat-btn-secondary:hover {
    background: #444;
    color: #fff;
}

/* ----- Shared utility ----- */
.chat-widget .hidden {
    display: none !important;
}

/* ----- Responsive ----- */
@media (max-width: 480px) {
    .chat-widget {
        right: 14px;
        bottom: 14px;
    }

    .chat-window {
        width: calc(100vw - 24px);
        right: -8px;
        bottom: 64px;
        max-height: calc(100vh - 100px);
        border-radius: 12px;
        box-sizing: border-box;
        overflow: hidden;
    }

    .chat-header {
        border-radius: 12px 12px 0 0;
    }

    .chat-toggle {
        width: 48px;
        height: 48px;
    }

    .chat-input-area {
        width: 100%;
        box-sizing: border-box;
    }

    .chat-msg-input {
        font-size: 16px;
        min-width: 0;
    }

    .chat-btn-send {
        flex-shrink: 0;
    }

    .chat-btn-image {
        flex-shrink: 0;
    }

    .chat-msg-image img {
        max-height: 160px;
    }
}

/* ----- Scrollbar (Webkit) ----- */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* ----- Loading/Typing indicators ----- */
.chat-typing {
    align-self: flex-start;
    font-size: 12px;
    color: #888;
    font-style: italic;
}


/* ──────────────────────────────────────────────────────────────
   Visitor Counter Widget
   ────────────────────────────────────────────────────────────── */

.vc-widget {
    width: 100%;
    max-width: 520px;
    margin: 8px auto;
    padding: 12px 10px;
    background: #1a1a1a;
    border: 1px solid #D93414;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #DB4D2A;
    font-size: 13px;
    line-height: 1.5;
    box-sizing: border-box;
}
.vc-widget .vc-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #DB4D2A;
    letter-spacing: 0.5px;
}
.vc-flags {
    display: grid;
    grid-template-columns: repeat(8, auto);
    justify-content: center;
    gap: 6px 10px;
    margin-bottom: 12px;
}
@media (max-width: 520px) {
    .vc-widget {
        max-width: 100%;
        padding: 12px 14px;
    }
    .vc-flags {
        grid-template-columns: repeat(6, 1fr);
        justify-content: stretch;
        gap: 6px 2px;
    }
    .vc-flag-row {
        gap: 1px;
    }
    .vc-flag-row .vc-flag {
        font-size: 14px;
    }
    .vc-flag-row .vc-code {
        font-size: 8px;
    }
    .vc-flag-row .vc-count {
        font-size: 9px;
    }
}
.vc-flag-row {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}
.vc-flag-row .vc-flag {
    font-size: 16px;
    line-height: 1;
}
.vc-flag-row .vc-code {
    font-size: 9px;
    font-weight: 600;
    color: #999;
}
.vc-flag-row .vc-count {
    font-size: 11px;
    color: #ccc;
}
.vc-totals {
    border-top: 1px solid #333;
    padding-top: 8px;
}
.vc-totals .vc-row {
    padding: 2px 0;
}
.vc-totals .vc-label {
    color: #888;
    font-size: 12px;
}
.vc-totals .vc-value {
    color: #DB4D2A;
    font-weight: 600;
    font-size: 12px;
    margin-left: 6px;
}
.vc-loading {
    text-align: center;
    color: #666;
    padding: 20px 0;
}


/* ──────────────────────────────────────────────────────────────
   Microblog Slider
   Structure:
     .mb-slider         — outer wrapper
       .mb-slides       — position: relative, overflow: hidden
         .mb-slide      — absolutely positioned, opacity crossfade
           .mb-slide-img
           .mb-caption  — overlay at the bottom of the image
       .mb-dots         — navigation dots row
         .mb-dot
     .mb-single         — single post (no carousel), position: relative
       .mb-caption      — same overlay
   ────────────────────────────────────────────────────────────── */

/* ── Single post wrapper ── */
.mb-single {
  position: relative;
  border-radius: 20px;
  margin-bottom: 25px;
}

.mb-single > .card-image {
  display: block;
  margin-bottom: 0;
}

.mb-single > .card-image:hover,
.mb-slide-img:hover {
  transform: none;
  box-shadow: none;
}

/* ── Slider outer wrapper ── */
.mb-slider {
  margin-bottom: 25px;
}

/* ── Slides viewport ── */
.mb-slides {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
}

/* ── Slides ── */
.mb-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.mb-slide.mb-slide-active {
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
}

/* ── Slide images ── */
.mb-slide-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
}

/* ── Card hover ── */
.card:has(.mb-slider):hover,
.card:has(.mb-single):hover {
  box-shadow: 6px 8px 5px rgba(250, 50, 50, 0.6);
  transition: box-shadow 0.3s ease;
}

/* ── Caption overlay ── */
.mb-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  line-height: 1.4;
  border-radius: 0 0 20px 20px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Navigation dots ── */
.mb-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
}

.mb-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.mb-dot:hover {
  transform: scale(1.3);
}

.mb-dot-active {
  background: rgba(250, 50, 50, 0.8);
  transform: scale(1.2);
}

/* ── Responsive ── */
@media (max-width: 520px) {
  .mb-caption {
    font-size: 12px;
    padding: 6px 10px;
  }

  .mb-dots {
    gap: 6px;
    padding: 8px 0 2px;
  }

  .mb-dot {
    width: 8px;
    height: 8px;
  }
}
