/* ============================================
   ZHEX LIVE CHAT — Dark Theme
   ============================================ */

:root {
    --zhex-bg: #0a0e17;
    --zhex-surface: #111827;
    --zhex-surface-2: #1a2236;
    --zhex-border: rgba(255,255,255,0.08);
    --zhex-text: #e2e8f0;
    --zhex-text-muted: #64748b;
    --zhex-accent: #6c5ce7;
    --zhex-accent-hover: #7c6ff7;
    --zhex-green: #10b981;
    --zhex-red: #ef4444;
    --zhex-orange: #f59e0b;
    --zhex-blue: #3b82f6;
    --zhex-msg-customer: #6c5ce7;
    --zhex-msg-admin: #1e293b;
    --zhex-msg-bot: #1a2236;
    --zhex-radius: 4px;
    --zhex-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--zhex-font);
    background: var(--zhex-bg);
    color: var(--zhex-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ============================================
   ENTRY PAGE (index.php)
   ============================================ */

.zhex-entry {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 0 0 0 8%;
}

.zhex-entry-inner {
    width: 100%;
    max-width: 460px;
}

.zhex-entry-logo {
    display: block;
    margin-bottom: 12px;
}

.zhex-entry-logo a {
    display: block;
    width: fit-content;
    transition: opacity 0.2s;
}

.zhex-entry-logo a:hover {
    opacity: 0.8;
}

.zhex-entry-logo img {
    display: block;
    width: 180px;
    height: 180px;
}

.zhex-entry-home-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding: 4px 0;
    font-size: 14px;
    color: var(--zhex-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.zhex-entry-home-link:hover {
    color: var(--zhex-accent);
}

/* Online/Offline Status */
.zhex-entry-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.zhex-status-online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--zhex-green);
}

.zhex-status-offline {
    background: rgba(245, 158, 11, 0.1);
    color: var(--zhex-orange);
}

.zhex-status-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    flex-shrink: 0;
}

.zhex-dot-online {
    background: var(--zhex-green);
    clip-path: circle(50%);
    animation: zhex-pulse 2s infinite;
}

.zhex-dot-offline {
    background: var(--zhex-orange);
    clip-path: circle(50%);
}

@keyframes zhex-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.zhex-entry-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
}

.zhex-entry-subtitle {
    font-size: 13px;
    color: var(--zhex-text-muted);
    margin-bottom: 16px;
}

.zhex-entry-error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--zhex-red);
    color: var(--zhex-red);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Form */
.zhex-entry-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zhex-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--zhex-text-muted);
}

.zhex-required { color: var(--zhex-red); }
.zhex-optional { color: var(--zhex-text-muted); font-weight: 400; }

.zhex-form-group input[type="email"],
.zhex-form-group input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--zhex-bg);
    border: 1px solid var(--zhex-border);
    color: var(--zhex-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.zhex-form-group input:focus {
    border-color: var(--zhex-accent);
}

.zhex-captcha-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zhex-captcha-question {
    font-size: 18px;
    font-weight: 600;
    color: var(--zhex-accent);
    white-space: nowrap;
    background: var(--zhex-bg);
    padding: 8px 16px;
    border: 1px solid var(--zhex-border);
}

.zhex-captcha-input {
    width: 80px;
    padding: 10px 14px;
    background: var(--zhex-bg);
    border: 1px solid var(--zhex-border);
    color: var(--zhex-text);
    font-size: 16px;
    text-align: center;
    outline: none;
}

.zhex-captcha-input:focus {
    border-color: var(--zhex-accent);
}

.zhex-entry-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: var(--zhex-accent);
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.zhex-entry-btn:hover {
    background: var(--zhex-accent-hover);
}

.zhex-entry-note {
    font-size: 12px;
    color: var(--zhex-text-muted);
    margin-top: 16px;
}

/* ============================================
   CHAT PAGE (chat.php)
   ============================================ */

.zhex-chat-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0;
}

.zhex-chat-wrapper {
    width: 100%;
    max-width: 900px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--zhex-surface);
    border-left: 1px solid var(--zhex-border);
    border-right: 1px solid var(--zhex-border);
}

/* Home link in chat header */
.zhex-chat-home-link {
    color: var(--zhex-text-muted);
    padding: 6px;
    transition: color 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.zhex-chat-home-link:hover {
    color: var(--zhex-accent);
}

/* Chat Header */
.zhex-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--zhex-surface-2);
    border-bottom: 1px solid var(--zhex-border);
    flex-shrink: 0;
}

.zhex-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zhex-chat-header-left img {
    width: 32px;
    height: 32px;
}

.zhex-chat-header-info {
    display: flex;
    flex-direction: column;
}

.zhex-chat-header-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.zhex-chat-header-status {
    font-size: 12px;
    color: var(--zhex-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.zhex-chat-end-btn {
    background: none;
    border: none;
    color: var(--zhex-text-muted);
    cursor: pointer;
    padding: 6px;
    transition: color 0.2s;
}

.zhex-chat-end-btn:hover {
    color: var(--zhex-red);
}

/* Offline Banner */
.zhex-chat-offline-banner {
    background: rgba(245, 158, 11, 0.1);
    color: var(--zhex-orange);
    padding: 10px 16px;
    font-size: 12px;
    text-align: center;
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    flex-shrink: 0;
}

/* Messages Area */
.zhex-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.zhex-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.zhex-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.zhex-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
}

/* Message Bubbles */
.zhex-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: zhex-fadeIn 0.2s ease;
}

@keyframes zhex-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.zhex-msg-customer {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.zhex-msg-admin,
.zhex-msg-bot {
    align-self: flex-start;
}

.zhex-msg-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--zhex-surface-2);
    border: 1px solid var(--zhex-border);
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
    color: var(--zhex-text-muted);
}

.zhex-msg-bot .zhex-msg-avatar {
    color: var(--zhex-accent);
    background: rgba(108, 92, 231, 0.1);
}

.zhex-msg-bubble {
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
}

.zhex-msg-customer .zhex-msg-bubble {
    background: var(--zhex-msg-customer);
    color: #fff;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
}

.zhex-msg-admin .zhex-msg-bubble {
    background: var(--zhex-msg-admin);
    border: 1px solid var(--zhex-border);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.zhex-msg-bot .zhex-msg-bubble {
    background: var(--zhex-msg-bot);
    border: 1px solid rgba(108, 92, 231, 0.15);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.zhex-msg-text {
    word-break: break-word;
    white-space: pre-wrap;
}

.zhex-msg-image img {
    max-width: 280px;
    max-height: 200px;
    cursor: pointer;
    margin-bottom: 4px;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

.zhex-msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.zhex-msg-time {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
}

.zhex-msg-seen {
    color: var(--zhex-blue);
}

.zhex-msg-seen svg {
    width: 14px;
    height: 14px;
}

/* Typing Indicator */
.zhex-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--zhex-text-muted);
}

.zhex-typing-dots {
    display: flex;
    gap: 3px;
}

.zhex-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--zhex-text-muted);
    clip-path: circle(50%);
    animation: zhex-bounce 1.4s infinite ease-in-out both;
}

.zhex-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.zhex-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes zhex-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Bar */
.zhex-chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--zhex-border);
    background: var(--zhex-surface-2);
    flex-shrink: 0;
}

.zhex-chat-attach-btn {
    color: var(--zhex-text-muted);
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.zhex-chat-attach-btn:hover {
    color: var(--zhex-accent);
}

.zhex-chat-input-wrap {
    flex: 1;
}

.zhex-chat-input-wrap textarea {
    width: 100%;
    min-height: 36px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    background: var(--zhex-bg);
    border: 1px solid var(--zhex-border);
    color: var(--zhex-text);
    padding: 8px 12px;
    font-size: 14px;
    font-family: var(--zhex-font);
    outline: none;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.zhex-chat-input-wrap textarea:focus {
    border-color: var(--zhex-accent);
}

.zhex-chat-send-btn {
    background: var(--zhex-accent);
    border: none;
    color: #fff;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}

.zhex-chat-send-btn:hover {
    background: var(--zhex-accent-hover);
}

/* Image Preview */
.zhex-chat-preview {
    position: relative;
    padding: 8px 16px;
    background: var(--zhex-surface-2);
    border-top: 1px solid var(--zhex-border);
}

.zhex-chat-preview img {
    max-height: 100px;
    max-width: 150px;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

.zhex-chat-preview-cancel {
    position: absolute;
    top: 4px;
    right: 20px;
    background: var(--zhex-red);
    color: #fff;
    border: none;
    width: 24px;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}

/* Image Modal */
.zhex-image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.zhex-image-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.zhex-image-modal-close {
    position: absolute;
    top: 20px;
    right: 24px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
}

/* Rating Modal */
.zhex-rating-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zhex-rating-card {
    background: var(--zhex-surface);
    border: 1px solid var(--zhex-border);
    padding: 32px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.zhex-rating-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #fff;
}

.zhex-rating-card p {
    font-size: 13px;
    color: var(--zhex-text-muted);
    margin-bottom: 20px;
}

.zhex-rating-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.zhex-star {
    font-size: 32px;
    background: none;
    border: none;
    color: var(--zhex-text-muted);
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    padding: 4px;
}

.zhex-star:hover,
.zhex-star.active {
    color: var(--zhex-orange);
    transform: scale(1.2);
}

.zhex-rating-skip {
    background: none;
    border: 1px solid var(--zhex-border);
    color: var(--zhex-text-muted);
    padding: 8px 24px;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s;
}

.zhex-rating-skip:hover {
    color: var(--zhex-text);
}

/* ============================================
   ADMIN PANEL
   ============================================ */

.zhex-admin {
    display: flex;
    height: 100vh;
}

.zhex-admin-sidebar {
    width: 320px;
    background: var(--zhex-surface);
    border-right: 1px solid var(--zhex-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.zhex-admin-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--zhex-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.zhex-admin-sidebar-header img {
    width: 28px;
    height: 28px;
}

.zhex-admin-sidebar-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.zhex-admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--zhex-border);
}

.zhex-admin-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: var(--zhex-text-muted);
    font-size: 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.zhex-admin-tab.active {
    color: var(--zhex-accent);
    border-bottom-color: var(--zhex-accent);
}

.zhex-admin-chat-list {
    flex: 1;
    overflow-y: auto;
}

.zhex-admin-chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--zhex-border);
    cursor: pointer;
    transition: background 0.15s;
}

.zhex-admin-chat-item:hover,
.zhex-admin-chat-item.active {
    background: var(--zhex-surface-2);
}

.zhex-admin-chat-item-info {
    flex: 1;
    min-width: 0;
}

.zhex-admin-chat-email {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zhex-admin-chat-preview {
    font-size: 11px;
    color: var(--zhex-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zhex-admin-chat-badge {
    background: var(--zhex-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    clip-path: polygon(0 0, calc(100% - 3px) 0, 100% 3px, 100% 100%, 3px 100%, 0 calc(100% - 3px));
}

.zhex-admin-chat-time {
    font-size: 10px;
    color: var(--zhex-text-muted);
    white-space: nowrap;
}

/* Admin Main Area */
.zhex-admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--zhex-bg);
}

.zhex-admin-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--zhex-text-muted);
    font-size: 14px;
}

/* Admin Info Panel (right side) */
.zhex-admin-info {
    width: 280px;
    background: var(--zhex-surface);
    border-left: 1px solid var(--zhex-border);
    overflow-y: auto;
    padding: 16px;
    flex-shrink: 0;
}

.zhex-admin-info h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--zhex-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    margin-top: 16px;
}

.zhex-admin-info h4:first-child {
    margin-top: 0;
}

.zhex-admin-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
}

.zhex-admin-info-label {
    color: var(--zhex-text-muted);
}

.zhex-admin-info-value {
    color: var(--zhex-text);
    text-align: right;
    word-break: break-all;
}

.zhex-admin-orders {
    margin-top: 8px;
}

.zhex-admin-order-item {
    background: var(--zhex-bg);
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 11px;
    border: 1px solid var(--zhex-border);
}

.zhex-admin-notes textarea {
    width: 100%;
    min-height: 60px;
    background: var(--zhex-bg);
    border: 1px solid var(--zhex-border);
    color: var(--zhex-text);
    padding: 8px;
    font-size: 12px;
    font-family: var(--zhex-font);
    resize: vertical;
    outline: none;
}

.zhex-admin-notes textarea:focus {
    border-color: var(--zhex-accent);
}

/* Admin action buttons */
.zhex-admin-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 11px;
    border: 1px solid var(--zhex-border);
    background: none;
    color: var(--zhex-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 8px;
    margin-right: 4px;
}

.zhex-admin-action-btn:hover {
    color: var(--zhex-text);
    border-color: var(--zhex-text-muted);
}

.zhex-admin-action-btn.danger {
    color: var(--zhex-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.zhex-admin-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Admin Quick Reply Dropdown */
.zhex-admin-quick-replies {
    position: relative;
}

.zhex-admin-quick-btn {
    background: none;
    border: 1px solid var(--zhex-border);
    color: var(--zhex-text-muted);
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.zhex-admin-quick-btn:hover {
    color: var(--zhex-accent);
    border-color: var(--zhex-accent);
}

.zhex-admin-quick-list {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--zhex-surface);
    border: 1px solid var(--zhex-border);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.zhex-admin-quick-list.show {
    display: block;
}

.zhex-admin-quick-item {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--zhex-border);
    transition: background 0.1s;
}

.zhex-admin-quick-item:hover {
    background: var(--zhex-surface-2);
}

.zhex-admin-quick-item-title {
    font-weight: 500;
    color: var(--zhex-accent);
    font-size: 11px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .zhex-chat-wrapper {
        max-width: 100%;
        border: none;
    }

    .zhex-msg {
        max-width: 92%;
    }

    .zhex-entry-card {
        padding: 24px 20px;
    }

    /* Admin: stack layout on mobile */
    .zhex-admin {
        flex-direction: column;
    }

    .zhex-admin-sidebar {
        width: 100%;
        max-height: 40vh;
    }

    .zhex-admin-info {
        display: none;
    }
}
