/* ═══════════════════════════════════════════════════════════
   WhatsApp Order Bot — Glassmorphism Dashboard
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-dark: #0a0a1a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent: #25d366;
    --accent-dim: rgba(37, 211, 102, 0.2);
    --accent-glow: 0 0 20px rgba(37, 211, 102, 0.3);
    --danger: #ff4757;
    --danger-dim: rgba(255, 71, 87, 0.2);
    --warning: #ffa502;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.bg-gradient {
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(37, 211, 102, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(37, 100, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(130, 87, 229, 0.05) 0%, transparent 50%);
}

/* ── Glass Card ──────────────────────────────────────── */

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
    border: none;
    border-radius: var(--radius-xs);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--accent-dim);
    color: var(--accent);
}

.btn:hover {
    background: rgba(37, 211, 102, 0.3);
    box-shadow: var(--accent-glow);
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: #2be06e;
    box-shadow: var(--accent-glow);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger-dim);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(255, 71, 87, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ── Status Dots ─────────────────────────────────────── */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-online {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.status-connecting {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.status-offline {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    overflow-y: auto;
    padding-top: 40px;
    padding-bottom: 40px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 24px;
    text-align: center;
    margin: auto;
}

.logo-section {
    margin-bottom: 24px;
}

.logo-icon {
    font-size: 56px;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 20px rgba(37, 211, 102, 0.4));
}

.logo-section h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 13px;
    margin-bottom: 24px;
}

/* QR Section */
.qr-section {
    margin-bottom: 24px;
}

.qr-wrapper {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 200px;
    justify-content: center;
}

.qr-image {
    width: 220px;
    height: 220px;
    image-rendering: pixelated;
}

.qr-placeholder {
    color: #333;
    text-align: center;
    font-size: 14px;
}

.qr-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 12px;
}

.qr-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.pairing-code {
    text-align: center;
    color: #333;
    font-size: 13px;
}

.pairing-code code {
    display: block;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 4px;
    margin-top: 4px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #ddd;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Connected */
.connected-section {
    margin-bottom: 24px;
}

.connected-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

/* Login */
.login-section {
    margin-bottom: 16px;
}

.divider {
    position: relative;
    margin: 16px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-glass);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 4px;
    display: none;
}

/* Controls */
.controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ════════════════════════════════════════════════════════ */

.dashboard-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    height: 100vh;
    gap: 0;
}

/* Sidebar */
.sidebar {
    border-radius: 0;
    border-right: 1px solid var(--border-glass);
    border-top: none;
    border-bottom: none;
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
}

.logo-small {
    font-size: 16px;
    font-weight: 700;
}

.connection-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 11px;
}

/* Nav Tabs */
.nav-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-glass);
}

.nav-tab {
    flex: 1;
    padding: 10px 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
}

.nav-tab:hover {
    color: var(--text-secondary);
}

.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.search-box {
    padding: 12px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.chat-item:hover {
    background: var(--bg-card-hover);
}

.chat-item.active {
    background: var(--accent-dim);
}

.chat-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.chat-item-time {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-item-count {
    background: var(--accent);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Orders */
.orders-list {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.order-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.order-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-new { background: var(--accent-dim); color: var(--accent); }
.status-confirmed { background: rgba(0, 123, 255, 0.2); color: #007bff; }
.status-cancelled { background: var(--danger-dim); color: var(--danger); }
.status-delivered { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); }

.order-details p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.order-items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}

.item-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.order-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Products */
.products-panel {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#productsEditor {
    flex: 1;
    width: 100%;
    min-height: 200px;
    padding: 12px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.03);
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    resize: none;
    outline: none;
    margin-bottom: 8px;
}

#productsEditor:focus {
    border-color: var(--accent);
}

/* Live Feed */
.live-feed {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.feed-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.feed-dir { flex-shrink: 0; }
.feed-number { color: var(--accent); font-weight: 600; flex-shrink: 0; }
.feed-text { flex: 1; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-time { color: var(--text-muted); flex-shrink: 0; font-size: 11px; }

/* ── Chat View (Main) ────────────────────────────────── */

.chat-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.chat-header {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-glass);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.chat-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-actions {
    display: flex;
    gap: 8px;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.messages-area {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(37, 211, 102, 0.03) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(130, 87, 229, 0.02) 0%, transparent 60%);
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    position: relative;
    animation: bubbleIn 0.2s ease;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.message-bubble.user {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

.message-bubble.bot {
    align-self: flex-end;
    background: var(--accent-dim);
    border-bottom-right-radius: 4px;
}

.bubble-content {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.bubble-time {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

/* Message Input */
.message-input-area {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-glass);
}

.message-input-area input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.message-input-area input:focus {
    border-color: var(--accent);
}

/* ── Empty States ────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-state.large {
    padding: 60px 20px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ── Scrollbar ───────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .login-card {
        padding: 24px 20px;
    }
}
