@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Background Animation */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.shape-2 {
    width: 250px;
    height: 250px;
    background: linear-gradient(45deg, #4facfe 0%, #00f2fe 100%);
    bottom: -100px;
    left: -100px;
    animation-delay: 5s;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(45deg, #43e97b 0%, #38f9d7 100%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 10s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 30px) scale(0.9);
    }
}

/* Container */
.container {
    width: 100%;
    height: 100%;
    max-width: 500px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Chat Container */
.chat-container {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 20px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.header-text h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 2px;
}

.status-text {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-text::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f9fafb;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px 16px;
    animation: fadeIn 0.5s ease-out;
}

.welcome-icon {
    font-size: 50px;
    margin-bottom: 12px;
    animation: wave 2s infinite;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(20deg); }
    75% { transform: rotate(-20deg); }
}

.welcome-message h2 {
    font-size: 22px;
    color: #1e293b;
    margin-bottom: 8px;
}

.welcome-message p {
    color: #64748b;
    font-size: 15px;
    line-height: 1.5;
}

/* Message Bubbles */
.message {
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-out;
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    display: inline-block;
    max-width: 85%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
}

.message.bot {
    justify-content: flex-start;
}

.message.bot .message-content {
    background: white;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-bottom-left-radius: 4px;
}

.message.user {
    justify-content: flex-end;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    border-bottom-right-radius: 4px;
}

/* Chat Input */
.chat-input-container {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

#userInput {
    flex: 1;
    padding: 12px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Vazirmatn', sans-serif;
    transition: all 0.3s ease;
    background: #f9fafb;
    min-height: 44px;
}

#userInput:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    min-width: 44px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

.input-hint {
    text-align: center;
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.input-hint a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    margin-right: 4px;
}

.input-hint a:active {
    opacity: 0.7;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: white;
    padding: 32px 24px;
    border-radius: 20px;
    text-align: center;
    width: 100%;
    max-width: 350px;
    animation: scaleUp 0.3s ease-out;
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.success-icon {
    margin-bottom: 20px;
}

.success-icon svg {
    width: 70px;
    height: 70px;
}

.success-circle {
    stroke-dasharray: 220;
    stroke-dashoffset: 220;
    animation: drawCircle 0.6s ease-out forwards;
}

.success-check {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: drawCheck 0.4s 0.6s ease-out forwards;
}

@keyframes drawCircle {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes drawCheck {
    to {
        stroke-dashoffset: 0;
    }
}

.modal-content h2 {
    font-size: 24px;
    color: #1e293b;
    margin-bottom: 10px;
}

.modal-content p {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 20px;
}

.loader {
    width: 35px;
    height: 35px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* تنظیمات ویژه موبایل */
@media (max-width: 640px) {
    .container {
        max-width: 100%;
        padding: 0;
    }

    .chat-container {
        border-radius: 0;
        box-shadow: none;
    }

    .chat-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .header-text h1 {
        font-size: 18px;
    }

    .status-text {
        font-size: 12px;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .logo svg {
        width: 32px;
        height: 32px;
    }

    .chat-messages {
        padding: 16px;
    }

    .welcome-message {
        padding: 30px 12px;
    }

    .welcome-icon {
        font-size: 44px;
    }

    .welcome-message h2 {
        font-size: 20px;
    }

    .welcome-message p {
        font-size: 14px;
    }

    .message-content {
        font-size: 13px;
        padding: 10px 12px;
    }

    .chat-input-container {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    #userInput {
        font-size: 16px; /* جلوگیری از زوم در iOS */
        padding: 10px 12px;
    }

    .input-hint {
        font-size: 12px;
    }

    .modal-content {
        padding: 28px 20px;
        max-width: 90%;
    }

    .modal-content h2 {
        font-size: 22px;
    }

    .modal-content p {
        font-size: 13px;
    }
}

/* تنظیمات ویژه صفحات با نداشتن notch */
@media (max-width: 640px) and (max-height: 700px) {
    .chat-header {
        padding: 12px 16px;
    }

    .welcome-message {
        padding: 20px 12px;
    }

    .welcome-icon {
        font-size: 40px;
        margin-bottom: 8px;
    }

    .welcome-message h2 {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .welcome-message p {
        font-size: 13px;
    }
}

/* رفع مشکل کیبورد در موبایل */
@media (max-width: 640px) {
    .chat-messages {
        padding-bottom: 20px;
    }
}

/* تنظیمات landscape موبایل */
@media (max-width: 900px) and (orientation: landscape) {
    .chat-header {
        padding: 10px 16px;
    }

    .header-text h1 {
        font-size: 16px;
    }

    .logo {
        width: 35px;
        height: 35px;
    }

    .welcome-message {
        padding: 20px 12px;
    }

    .welcome-icon {
        font-size: 36px;
    }

    .chat-input-container {
        padding: 8px 12px;
    }
}
