/**
 * BizCity AI Agent Home — Styles
 * Header + Auth dialog + Guest welcome + Dashboard overrides for frontend context
 *
 * @package BizCity_WebChat_Bot
 * @since 2.0.0
 */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
body.aiagent-home-body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #1a1a2e;
}

/* ===== HEADER ===== */
/* Header is now hidden - controls moved to touchbar */
.aiagent-header {
    display: none !important;
}
/* Adjust dashboard height when header is hidden */
.aiagent-home-body .bizc-dash {
    height: 98vh !important;
}
.aiagent-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.aiagent-header-logo {
    display: flex; align-items: center; gap: 8px;
}
.aiagent-header-logo img {
    height: 32px; width: auto; border-radius: 8px;
}
.aiagent-header-logo .logo-text {
    font-weight: 700; font-size: 16px; color: #1a1a2e;
}
.aiagent-header-title {
    font-size: 15px; font-weight: 600; color: #333;
    flex: 1;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
}

/* ===== NEW CHAT BUTTON (header) ===== */
.aiagent-newchat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(99,102,241,0.08);
    color: #4f46e5;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
.aiagent-newchat-btn:hover {
    background: rgba(99,102,241,0.18);
    transform: scale(1.05);
}
.aiagent-newchat-btn:active {
    transform: scale(0.92);
}
.aiagent-newchat-btn svg {
    display: block;
}
.aiagent-header-right {
    display: flex; align-items: center; gap: 10px;
}
.aiagent-user-name {
    font-size: 13px; color: #6b7280; font-weight: 500;
}
.aiagent-btn-register {
    padding: 8px 16px; border-radius: 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
    border: none; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.aiagent-btn-register:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(99,102,241,0.4); }
.aiagent-btn-login {
    padding: 8px 16px; border-radius: 20px;
    background: #fff; color: #6366f1;
    border: 1.5px solid #c7d2fe; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    text-decoration: none;
}
.aiagent-btn-login:hover { background: #f5f3ff; border-color: #a5b4fc; }

/* ===== DASHBOARD OVERRIDES for frontend ===== */
/* Header hidden - use full height */
.aiagent-home-body .bizc-dash {
    height: 100vh !important;
}
/* Admin-specific overrides target elements that don't exist on frontend — harmless, but clean up */
.aiagent-home-body #wpbody-content,
.aiagent-home-body #wpcontent {
    padding: 0 !important;
}

/* ===== GUEST WELCOME ===== */
.aiagent-guest-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #e5deff 0%, #d5e5ff 50%, #e0f0ff 100%);
    padding: 10px;
}
.aiagent-guest-center {
    text-align: center;
    padding: 40px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(99,102,241,0.12);
    max-width: 560px;
    width: 100%;
}
.aiagent-guest-center .aiagent-char-avatar {
    width: 100px; height: 100px;
    border-radius: 50%;
    border: 3px solid rgba(99,102,241,0.2);
    margin: 0 auto 20px;
    overflow: hidden;
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
    display: flex; align-items: center; justify-content: center;
}
.aiagent-guest-center .aiagent-char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aiagent-guest-center .avatar-emoji { font-size: 42px; }
.aiagent-guest-title {
    font-size: 28px; font-weight: 700; color: #1a1a2e; margin: 0 0 8px;
}
.aiagent-guest-desc {
    font-size: 16px; color: #6b7280; margin: 0 0 20px; line-height: 1.5;
}

/* Fake chat input bar (guest) */
.aiagent-guest-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f3ff;
    border: 1.5px solid #e0e7ff;
    border-radius: 50px;
    padding: 8px 8px 8px 20px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto 14px;
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.aiagent-guest-input-bar:hover {
    background: #ede9fe;
    border-color: #a5b4fc;
}
.aiagent-guest-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    padding: 0 !important;
    height: auto !important;
    font-size: 15px;
    color: #374151;
    background: transparent !important;
    cursor: pointer;
    pointer-events: none;
    font-family: inherit;
}
.aiagent-guest-input::placeholder { color: #9ca3af; }
.aiagent-guest-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(99,102,241,0.25);
    font-size: 0;
}
.aiagent-guest-send-btn .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    line-height: 1;
}
.aiagent-guest-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(99,102,241,0.4);
}
.aiagent-guest-hint {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

/* ===== LOGIN DIALOG (WooCommerce form) ===== */
.aiagent-auth-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.aiagent-auth-overlay.active { display: flex; }
.aiagent-wc-dialog {
    background: #fff;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}
.aiagent-auth-close {
    position: absolute; top: 10px; right: 14px;
    font-size: 26px; line-height: 1;
    color: #aaa; cursor: pointer;
    background: none; border: none; z-index: 2;
    transition: color 0.2s;
}
.aiagent-auth-close:hover { color: #333; }

/* ===== HAMBURGER BUTTON ===== */
.aiagent-hamburger {
    display: none; /* hidden on desktop */
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.aiagent-hamburger:hover { background: rgba(99,102,241,0.08); }
.aiagent-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #1a1a2e;
    border-radius: 2px;
    transition: all 0.3s ease;
}
/* Animate to X when open */
.aiagent-hamburger.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.aiagent-hamburger.open span:nth-child(2) {
    opacity: 0;
}
.aiagent-hamburger.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ===== MOBILE DRAWER BACKDROP ===== */
.aiagent-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.aiagent-drawer-backdrop.active {
    display: block;
    opacity: 1;
}

/* ===== GUEST MOBILE DRAWER ===== */
.aiagent-guest-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: 0 20px 20px 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}
.aiagent-guest-drawer.mobile-open {
    transform: translateX(0);
}
.aiagent-drawer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid #f3f4f6;
}
.aiagent-drawer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
}
.aiagent-drawer-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
}
.aiagent-drawer-body {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}
.aiagent-drawer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a2e;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}
.aiagent-drawer-item:hover {
    background: rgba(99,102,241,0.06);
}
.aiagent-drawer-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.aiagent-drawer-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 6px 14px;
}
.aiagent-drawer-footer {
    padding: 14px 16px;
    border-top: 1px solid #f3f4f6;
    text-align: center;
}

/* ===== PROFILE TRIGGER BUTTON (mobile only) ===== */
.aiagent-profile-trigger {
    display: none; /* hidden on desktop */
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    background: #f3f4f6;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    line-height: 0;
}
.aiagent-profile-trigger:hover {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139,92,246,0.15);
}
.aiagent-profile-trigger-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ===== RIGHT DRAWER (user profile) ===== */
.aiagent-right-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    transform: translateX(110%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    border-left: 1px solid #e5e7eb;
}
.aiagent-right-drawer.mobile-open {
    transform: translateX(0);
    box-shadow: -2px 0 8px rgba(0,0,0,0.08);
}
.aiagent-rd-section {
    padding: 16px;
}
.aiagent-rd-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.aiagent-rd-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(99,102,241,0.2);
    flex-shrink: 0;
}
.aiagent-rd-user-info {
    flex: 1;
    min-width: 0;
}
.aiagent-rd-name {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aiagent-rd-email {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aiagent-rd-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 0;
    font-size: 13px;
    color: #374151;
}
.aiagent-rd-meta-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.aiagent-rd-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.aiagent-rd-assistant {
    display: flex;
    align-items: center;
    gap: 10px;
}
.aiagent-rd-bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}
.aiagent-rd-bot-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
}
.aiagent-rd-bot-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

/* Rolling Memory tracker in right drawer */
.aiagent-rolling-memory {
    margin-top: 8px;
    border-top: 1px solid rgba(99,102,241,0.1);
    padding-top: 8px;
}
.aiagent-rm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.aiagent-rm-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.aiagent-rm-item {
    background: linear-gradient(135deg, #f0f0ff 0%, #faf5ff 100%);
    border: 1px solid rgba(99,102,241,0.12);
    border-radius: 10px;
    padding: 8px 10px;
    position: relative;
    overflow: hidden;
}
.aiagent-rm-item.completed {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-color: rgba(34,197,94,0.15);
}
.aiagent-rm-item.cancelled {
    background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
    border-color: rgba(239,68,68,0.12);
}
.aiagent-rm-goal {
    font-size: 12px;
    font-weight: 600;
    color: #1e1b4b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aiagent-rm-summary {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.aiagent-rm-scores {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}
.aiagent-rm-score {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #6366f1;
}
.aiagent-rm-score-bar {
    width: 40px;
    height: 4px;
    background: rgba(99,102,241,0.15);
    border-radius: 2px;
    overflow: hidden;
}
.aiagent-rm-score-fill {
    height: 100%;
    border-radius: 2px;
    background: #6366f1;
    transition: width 0.5s ease;
}
.aiagent-rm-score.satisfaction .aiagent-rm-score-fill {
    background: #22c55e;
}

.aiagent-rd-links .aiagent-drawer-item {
    text-decoration: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .aiagent-hamburger { display: flex; } /* show hamburger */
    .aiagent-profile-trigger { display: flex; } /* show avatar trigger */
    .aiagent-header-logo .logo-text { display: none; } /* hide logo text */
    .aiagent-header { padding: 8px 12px; }
    .aiagent-header-title {
        font-size: 13px;
        max-width: 45vw;
    }
    .aiagent-btn-register { padding: 6px 12px; font-size: 12px; }
    .aiagent-btn-login { display: none; } /* hide text buttons, show avatar instead */
    .aiagent-user-name { display: none; }
    .aiagent-guest-center { padding: 24px 16px; }
    .aiagent-guest-title { font-size: 22px; }
    .aiagent-guest-desc { font-size: 14px; }
}
@media (max-width: 480px) {
    .aiagent-guest-drawer,
    .aiagent-home-body .bizc-sidebar {
        width: 85vw;
    }
    .aiagent-right-drawer {
        width: 85vw;
    }
}
