/* ===================================================================
   FITNESS TIME AI CHATBOT (NOUF) - OFFICIAL BRAND DESIGN SYSTEM
   Bilingual (AR/EN) • Sleek • Compact • High-Performance Athletic Dark
   =================================================================== */

:root {
    /* Fitness Time Brand Colors */
    --ft-red: #E31837;
    --ft-red-hover: #C41230;
    --ft-red-dark: #960D24;
    --ft-red-subtle: rgba(227, 24, 55, 0.12);
    --ft-red-border: rgba(227, 24, 55, 0.3);
    --ft-red-glow: rgba(227, 24, 55, 0.25);

    /* Pure White & Neutral Tones */
    --ft-white: #FFFFFF;
    --ft-white-soft: #EDEDF0;
    --ft-gray-light: #C8CAD0;
    --ft-gray-muted: #8E929E;
    --ft-gray-dark: #4A4D57;

    /* Deep Athletic Blacks & Surfaces */
    --ft-black-base: #0B0B0D;
    --ft-black-surface: #121317;
    --ft-black-card: #17181E;
    --ft-black-card-hover: #1E2028;
    --ft-black-input: #0F1013;
    --ft-border: rgba(255, 255, 255, 0.08);
    --ft-border-light: rgba(255, 255, 255, 0.14);
    --ft-border-red: rgba(227, 24, 55, 0.35);

    /* Status */
    --ft-green: #10B981;
    --ft-green-glow: rgba(16, 185, 129, 0.35);

    /* Typography & Radius */
    --font-ar: 'Cairo', system-ui, -apple-system, sans-serif;
    --font-en: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    --radius-xs: 6px;
    --radius-sm: 9px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-pill: 9999px;
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Box-Sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--ft-black-base);
    color: var(--ft-white);
    font-family: var(--font-ar);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* LTR Support when English is active */
html[dir="ltr"], html[lang="en"] {
    direction: ltr;
    text-align: left;
    font-family: var(--font-en);
}

html[dir="rtl"], html[lang="ar"] {
    direction: rtl;
    text-align: right;
    font-family: var(--font-ar);
}

/* Main Responsive Container */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--ft-black-base);
    border-left: 1px solid var(--ft-border);
    border-right: 1px solid var(--ft-border);
    position: relative;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background-color: var(--ft-black-surface);
    border-bottom: 1px solid var(--ft-border);
    flex-shrink: 0;
    z-index: 10;
    gap: 12px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: var(--transition);
}

.brand-logo-link:hover {
    opacity: 0.85;
}

.ft-logo-img {
    height: 26px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    display: block;
}

.brand-divider {
    width: 1px;
    height: 24px;
    background-color: var(--ft-border-light);
}

.agent-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.25;
}

.agent-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ft-white);
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.agent-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--ft-gray-muted);
}

.status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--ft-green);
    box-shadow: 0 0 8px var(--ft-green);
    animation: pulse 2.2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.9); }
}

.status-text {
    font-weight: 600;
    color: var(--ft-green);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background-color: var(--ft-black-card);
    border: 1px solid var(--ft-border);
    color: var(--ft-gray-light);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-action:hover {
    background-color: var(--ft-black-card-hover);
    border-color: var(--ft-border-light);
    color: var(--ft-white);
}

.btn-lang {
    background-color: rgba(255, 255, 255, 0.04);
}

.btn-lang:hover {
    border-color: var(--ft-red);
    color: var(--ft-white);
}

.btn-reset {
    padding: 6px 8px;
}

.btn-reset:hover {
    background-color: var(--ft-red);
    border-color: var(--ft-red);
    color: var(--ft-white);
}

.action-icon {
    flex-shrink: 0;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

.chat-main::-webkit-scrollbar {
    width: 5px;
}
.chat-main::-webkit-scrollbar-track {
    background: transparent;
}
.chat-main::-webkit-scrollbar-thumb {
    background-color: var(--ft-border);
    border-radius: 4px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===================================================================
   COMPACT WELCOME CARD (Redesigned per user request)
   Subtle • Elegant • Small vertical footprint • No thick red borders
   =================================================================== */
.welcome-card {
    background: linear-gradient(145deg, #15161B, #101114);
    border: 1px solid var(--ft-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 4px;
    animation: fadeIn 0.25s ease-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.welcome-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.welcome-avatar-wrap {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(227, 24, 55, 0.35);
}

.welcome-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.welcome-title-group {
    flex: 1;
    min-width: 0;
}

.welcome-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ft-white);
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.welcome-desc {
    color: var(--ft-gray-light);
    font-size: 0.84rem;
    line-height: 1.45;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.feat-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    background-color: var(--ft-black-card);
    border: 1px solid var(--ft-border);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--ft-white-soft);
    font-weight: 600;
    transition: var(--transition);
}

.feat-pill:hover {
    border-color: var(--ft-border-light);
    background-color: var(--ft-black-card-hover);
}

.feat-icon {
    color: var(--ft-red);
    flex-shrink: 0;
}

/* ===================================================================
   CHAT MESSAGES & BUBBLES (Clean SVGs • No emojis)
   =================================================================== */
.msg-row {
    display: flex;
    gap: 10px;
    animation: slideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-width: 88%;
}

.msg-user {
    align-self: flex-start;
    flex-direction: row;
}

.msg-agent {
    align-self: flex-start;
    flex-direction: row;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.msg-user .msg-avatar {
    background-color: #242630;
    color: var(--ft-gray-light);
}

.msg-agent .msg-avatar {
    background: transparent;
    overflow: hidden;
    box-shadow: none;
    padding: 0;
}

.avatar-ft-img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-xs);
    object-fit: cover;
    display: block;
}

.msg-bubble {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    position: relative;
    word-break: break-word;
    font-size: 0.9rem;
    line-height: 1.55;
}

.msg-user .msg-bubble {
    background-color: var(--ft-red);
    color: var(--ft-white);
    border-top-right-radius: var(--radius-xs);
    border-top-left-radius: var(--radius-md);
}

html[dir="ltr"] .msg-user .msg-bubble {
    border-top-right-radius: var(--radius-md);
    border-top-left-radius: var(--radius-xs);
}

.msg-agent .msg-bubble {
    background-color: var(--ft-black-card);
    border: 1px solid var(--ft-border);
    color: var(--ft-white-soft);
    border-top-right-radius: var(--radius-xs);
}

html[dir="ltr"] .msg-agent .msg-bubble {
    border-top-right-radius: var(--radius-md);
    border-top-left-radius: var(--radius-xs);
}

.msg-text p {
    margin-bottom: 8px;
}
.msg-text p:last-child {
    margin-bottom: 0;
}

.msg-text ul {
    margin: 6px 18px;
}

.msg-text li {
    margin-bottom: 4px;
}

.msg-text strong {
    color: var(--ft-white);
    font-weight: 700;
}

.msg-text a {
    color: var(--ft-red);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--ft-border);
}

.msg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border-radius: var(--radius-xs);
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ft-border);
    color: var(--ft-gray-muted);
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    transition: var(--transition);
}

.msg-btn:hover {
    color: var(--ft-white);
    border-color: var(--ft-border-light);
    background-color: rgba(255, 255, 255, 0.08);
}

.msg-btn svg {
    flex-shrink: 0;
}

/* Typing Indicator */
.typing-indicator-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    animation: fadeIn 0.2s ease-out;
}

.typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    background: linear-gradient(135deg, var(--ft-red), #960D24);
    color: var(--ft-white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-bubble {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 14px;
    min-height: 32px;
    background-color: var(--ft-black-card);
    border: 1px solid var(--ft-border);
    border-radius: var(--radius-pill);
}

.typing-label {
    font-size: 0.78rem;
    color: var(--ft-gray-muted);
    font-weight: 600;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--ft-red);
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* ===================================================================
   FLOATING FOOTER & INPUT (Clean • No heavy red box)
   =================================================================== */
.chat-footer {
    padding: 10px 16px 12px;
    background-color: var(--ft-black-surface);
    border-top: 1px solid var(--ft-border);
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.chat-input-form {
    width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--ft-black-input);
    border: 1px solid var(--ft-border);
    border-radius: var(--radius-lg);
    padding: 6px 8px 6px 14px;
    transition: var(--transition);
}

html[dir="ltr"] .input-wrapper {
    padding: 6px 14px 6px 8px;
}

.input-wrapper:focus-within {
    border-color: var(--ft-red);
    box-shadow: 0 0 0 2px var(--ft-red-glow);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--ft-white);
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    padding: 4px 0;
    
    /* Hide scrollbar */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.chat-input::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.chat-input::placeholder {
    color: var(--ft-gray-muted);
}

.btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--ft-red);
    border: none;
    color: var(--ft-white);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.btn-send:hover:not(:disabled) {
    background-color: var(--ft-red-hover);
    transform: scale(1.04);
}

.btn-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* RTL Arrow flip */
html[dir="rtl"] .send-icon {
    transform: scaleX(-1);
}

.footer-caption {
    text-align: center;
    font-size: 0.72rem;
    color: var(--ft-gray-muted);
    margin-top: 6px;
    letter-spacing: 0.2px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--ft-black-card);
    border: 1px solid var(--ft-border-light);
    color: var(--ft-white);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.2s ease-out;
}

/* Utility */
.hidden {
    display: none !important;
}

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

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

/* ===================================================================
   RESPONSIVE MEDIA QUERIES (Mobile & Tablet Optimization)
   =================================================================== */
@media (max-width: 680px) {
    .chat-header {
        padding: 10px 14px;
    }

    .ft-logo-img {
        height: 22px;
        max-width: 120px;
    }

    .brand-divider {
        display: none;
    }

    .agent-name {
        font-size: 0.82rem;
    }

    .btn-action {
        padding: 5px 9px;
        font-size: 0.74rem;
    }

    .action-btn-text {
        display: inline;
    }

    .welcome-card {
        padding: 12px 14px;
    }

    .welcome-title {
        font-size: 0.96rem;
    }

    .welcome-desc {
        font-size: 0.8rem;
    }

    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .feat-pill {
        padding: 6px 8px;
        font-size: 0.74rem;
    }

    .chat-main {
        padding: 12px 12px;
    }

    .msg-row {
        max-width: 95%;
    }

    .chat-footer {
        padding: 8px 12px 10px;
    }

    .input-wrapper {
        padding: 4px 6px 4px 10px;
    }

    html[dir="ltr"] .input-wrapper {
        padding: 4px 10px 4px 6px;
    }

    .chat-input {
        font-size: 0.84rem;
    }

    .btn-send {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 400px) {
    .agent-info {
        display: none;
    }
    
    .btn-action {
        padding: 5px 8px;
    }
}
