/* ============================================
   PersianPDF ChatBot - Styles
   ============================================ */

:root {
    --ppcb-primary: #2563eb;
    --ppcb-primary-dark: #1d4ed8;
    --ppcb-primary-light: #dbeafe;
    --ppcb-success: #059669;
    --ppcb-success-light: #d1fae5;
    --ppcb-danger: #dc2626;
    --ppcb-danger-light: #fee2e2;
    --ppcb-gray-50: #f9fafb;
    --ppcb-gray-100: #f3f4f6;
    --ppcb-gray-200: #e5e7eb;
    --ppcb-gray-300: #d1d5db;
    --ppcb-gray-500: #6b7280;
    --ppcb-gray-700: #374151;
    --ppcb-gray-900: #111827;
    --ppcb-radius: 12px;
    --ppcb-shadow: 0 10px 40px rgba(0,0,0,0.12);
    --ppcb-font: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
}

/* ---- Floating Widget ---- */

.ppcb-floating {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    font-family: var(--ppcb-font);
    direction: rtl;
}

.ppcb-float-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ppcb-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.ppcb-float-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}

.ppcb-float-toggle.active {
    background: var(--ppcb-gray-700);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.ppcb-float-toggle.active svg {
    display: none;
}

.ppcb-float-toggle.active::after {
    content: '✕';
    font-size: 22px;
}

.ppcb-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: var(--ppcb-danger);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ppcb-pulse 2s infinite;
}

@keyframes ppcb-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.ppcb-float-panel {
    position: absolute;
    bottom: 72px;
    left: 0;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: var(--ppcb-radius);
    box-shadow: var(--ppcb-shadow);
    overflow: hidden;
    display: none;
    flex-direction: column;
    animation: ppcb-slideUp 0.3s ease;
}

.ppcb-float-panel.open {
    display: flex;
}

@keyframes ppcb-slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.ppcb-float-header {
    background: var(--ppcb-primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    font-weight: 600;
}

.ppcb-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
}

.ppcb-close-btn:hover {
    opacity: 1;
}

/* ---- Chat Container (shared) ---- */

.ppcb-chat-container {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px;
    flex: 1;
    direction: rtl;
    font-family: var(--ppcb-font);
    max-height: 400px;
}

.ppcb-chat-container.ppcb-is-page {
    max-height: 600px;
}

/* ---- Messages ---- */

.ppcb-msg {
    margin-bottom: 12px;
    animation: ppcb-fadeIn 0.35s ease;
}

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

.ppcb-msg-bot {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.ppcb-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ppcb-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ppcb-msg-bubble {
    background: var(--ppcb-gray-100);
    border-radius: 14px 14px 4px 14px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--ppcb-gray-900);
    max-width: 85%;
}

.ppcb-msg-user .ppcb-msg-bubble {
    background: var(--ppcb-primary);
    color: #fff;
    border-radius: 14px 14px 14px 4px;
    margin-right: auto;
    margin-left: 0;
}

.ppcb-msg-user {
    display: flex;
    justify-content: flex-end;
}

/* ---- Input Area ---- */

.ppcb-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--ppcb-gray-200);
    background: #fff;
}

.ppcb-input {
    flex: 1;
    border: 2px solid var(--ppcb-gray-200);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--ppcb-font);
    direction: ltr;
    text-align: left;
    outline: none;
    transition: border-color 0.2s;
}

.ppcb-input:focus {
    border-color: var(--ppcb-primary);
}

.ppcb-input::placeholder {
    direction: rtl;
    text-align: right;
    color: var(--ppcb-gray-500);
}

.ppcb-send-btn {
    background: var(--ppcb-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
    font-family: var(--ppcb-font);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.ppcb-send-btn:hover {
    background: var(--ppcb-primary-dark);
}

.ppcb-send-btn:disabled {
    background: var(--ppcb-gray-300);
    cursor: not-allowed;
}

/* ---- Loading Dots ---- */

.ppcb-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}

.ppcb-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--ppcb-gray-300);
    border-radius: 50%;
    animation: ppcb-bounce 1.4s ease infinite;
}

.ppcb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ppcb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ppcb-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* ---- Order Cards ---- */

.ppcb-order-card {
    background: #fff;
    border: 1px solid var(--ppcb-gray-200);
    border-radius: 10px;
    padding: 14px;
    margin-top: 10px;
}

.ppcb-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--ppcb-gray-500);
}

.ppcb-order-id {
    font-weight: 700;
    color: var(--ppcb-primary);
}

.ppcb-product-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--ppcb-gray-100);
}

.ppcb-product-item:first-child {
    border-top: none;
}

.ppcb-product-img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--ppcb-gray-100);
    flex-shrink: 0;
}

.ppcb-product-img-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--ppcb-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.ppcb-product-info {
    flex: 1;
    min-width: 0;
}

.ppcb-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ppcb-gray-900);
    margin-bottom: 6px;
}

.ppcb-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ppcb-success);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-family: var(--ppcb-font);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.ppcb-download-btn:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
    color: #fff;
}

.ppcb-download-btn:active {
    transform: translateY(0);
}

.ppcb-download-btn.downloading {
    opacity: 0.7;
    pointer-events: none;
}

.ppcb-file-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.ppcb-backup-link {
    font-size: 11px;
    color: var(--ppcb-gray-500);
    text-decoration: none;
    transition: color 0.2s;
}

.ppcb-backup-link:hover {
    color: var(--ppcb-primary);
    text-decoration: underline;
}

/* ---- Success Badge ---- */

.ppcb-success-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--ppcb-success-light);
    color: var(--ppcb-success);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ---- Try Again Button ---- */

.ppcb-try-again {
    display: inline-block;
    margin-top: 10px;
    background: var(--ppcb-primary-light);
    color: var(--ppcb-primary);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-family: var(--ppcb-font);
    cursor: pointer;
    transition: background 0.2s;
}

.ppcb-try-again:hover {
    background: #bfdbfe;
}

/* ---- Page Widget ---- */

.ppcb-page-widget {
    max-width: 640px;
    margin: 20px auto;
    font-family: var(--ppcb-font);
    direction: rtl;
}

.ppcb-page-header {
    text-align: center;
    margin-bottom: 20px;
}

.ppcb-page-header h2 {
    font-size: 22px;
    color: var(--ppcb-gray-900);
    margin-bottom: 8px;
}

.ppcb-page-header p {
    color: var(--ppcb-gray-500);
    font-size: 14px;
}

.ppcb-page-widget .ppcb-chat-container {
    background: #fff;
    border: 1px solid var(--ppcb-gray-200);
    border-radius: var(--ppcb-radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* ---- Standalone Page ---- */

.ppcb-standalone-page {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ppcb-font);
    direction: rtl;
}

.ppcb-standalone-wrapper {
    width: 100%;
    max-width: 680px;
    padding: 24px;
}

.ppcb-standalone-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--ppcb-shadow);
    overflow: hidden;
}

.ppcb-standalone-header {
    background: var(--ppcb-primary);
    color: #fff;
    padding: 28px 32px;
    text-align: center;
}

.ppcb-standalone-header h1 {
    font-size: 24px;
    margin: 0 0 8px;
}

.ppcb-standalone-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.ppcb-back-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 13px;
    display: inline-block;
    margin-bottom: 12px;
    transition: color 0.2s;
}

.ppcb-back-link:hover {
    color: #fff;
}

.ppcb-standalone-card .ppcb-chat-container {
    max-height: 500px;
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    .ppcb-float-panel {
        width: calc(100vw - 32px);
        left: 16px;
        bottom: 80px;
        max-height: 70vh;
    }

    .ppcb-floating {
        bottom: 16px;
        left: 16px;
    }

    .ppcb-float-toggle {
        width: 52px;
        height: 52px;
    }

    .ppcb-standalone-wrapper {
        padding: 12px;
    }
}

/* ---- Lift above theme's mobile bottom nav (≤900px) ---- */
/* نوار پایین موبایل قالب حدود ۶۲px ارتفاع دارد؛ دکمه چت‌بات را بالاتر می‌بریم
   تا روی آیتم «حساب من» نیفتد. این بلاک بعد از بلاک ۴۸۰px آمده تا اولویت داشته باشد. */
@media (max-width: 900px) {
    .ppcb-floating {
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        left: 16px;
    }
    .ppcb-float-panel {
        max-height: calc(100vh - 160px);
    }
}

/* ---- Scrollbar ---- */

.ppcb-chat-container::-webkit-scrollbar {
    width: 5px;
}

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

.ppcb-chat-container::-webkit-scrollbar-thumb {
    background: var(--ppcb-gray-300);
    border-radius: 10px;
}
