.aichat-page-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.aichat-page-title {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.aichat-instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.aichat-instructions h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #4a90e2;
}

.aichat-instructions p {
    margin: 8px 0;
    color: #666;
}

.aichat-user-status {
    font-weight: bold;
    color: #4a90e2;
    margin-top: 15px;
}

#ai-chat-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.aichat-topbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 20px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aichat-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aichat-fullscreen-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}

.aichat-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

body.aichat-fullscreen-mode {
    overflow: hidden !important;
}

#ai-chat-container.aichat-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
}

#ai-chat-container.aichat-fullscreen .aichat-messages {
    height: calc(100vh - 220px) !important;
}

.aichat-usage-info {
    font-size: 14px;
}

.aichat-model-selector {
    display: flex;
    gap: 12px;
    padding: 10px 20px;
    align-items: center;
    flex-wrap: nowrap;
    flex: 1;
}

.aichat-model-selector select {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    min-width: 140px;
    flex-shrink: 0;
}

.aichat-web-search {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #666;
}

.aichat-web-search input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.aichat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

.aichat-message {
    margin-bottom: 15px;
    display: flex;
}

.aichat-message-user {
    justify-content: flex-end;
}

.aichat-message-bot {
    justify-content: flex-start;
}

.aichat-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
}

.aichat-message-user .aichat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aichat-message-bot .aichat-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #eaecef;
    border-bottom-left-radius: 4px;
}

.aichat-message-content p {
    margin: 8px 0;
}

.aichat-message-content pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

.aichat-message-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.aichat-message-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 10px 0;
}

.aichat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.aichat-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.aichat-typing span:nth-child(1) {
    animation-delay: 0s;
}

.aichat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.aichat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.aichat-input-wrapper {
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #eaecef;
}

.aichat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.aichat-file-upload {
    cursor: pointer;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.aichat-file-upload:hover {
    background: #eaecef;
}

.aichat-file-upload input {
    display: none;
}

.aichat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
}

.aichat-input-area textarea:focus {
    outline: none;
    border-color: #4a90e2;
}

.aichat-input-area button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s;
}

.aichat-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.aichat-input-area button:hover:not(:disabled) {
    opacity: 0.9;
}

.aichat-action-buttons {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background: #f5f5f5;
}

.aichat-action-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

#loadHistoryBtn {
    background: #4a90e2;
    color: #fff;
}

#clearChatBtn {
    background: #e74c3c;
    color: #fff;
}

.aichat-action-buttons button:hover {
    opacity: 0.9;
}

#historyLoadingIndicator {
    text-align: center;
    padding: 20px;
    color: #666;
    background: #fff8e1;
    border-radius: 8px;
    margin: 10px;
}

@media (max-width: 768px) {
    .aichat-page-container {
        padding: 10px;
    }
    
    .aichat-messages {
        height: 400px;
    }
    
    .aichat-model-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .aichat-input-area {
        flex-wrap: wrap;
    }
    
    .aichat-input-area button {
        width: 100%;
    }
}

.aichat-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.aichat-toggle input {
    display: none;
}

.aichat-toggle-slider {
    position: relative;
    width: 40px;
    height: 20px;
    background: #ccc;
    border-radius: 10px;
    transition: 0.3s;
}

.aichat-toggle-slider:before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.aichat-toggle input:checked + .aichat-toggle-slider {
    background: #4a90e2;
}

.aichat-toggle input:checked + .aichat-toggle-slider:before {
    transform: translateX(20px);
}

.aichat-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eaecef;
}

.aichat-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.aichat-btn-secondary {
    background: #fff;
    color: #5f6368;
    border: 1px solid #dadce0;
}

.aichat-btn-secondary:hover {
    background: #f8f9fa;
    border-color: #4a90e2;
    color: #4a90e2;
}

.aichat-loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.aichat-loading span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: aichat-dot 1.4s infinite ease-in-out both;
}

.aichat-loading span:nth-child(1) { animation-delay: -0.32s; }
.aichat-loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aichat-dot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.aichat-message-error .aichat-message-content {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.aichat-input-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    gap: 20px;
    border-top: 1px solid #f0f2f5;
    background: #fafafa;
}

.aichat-create-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.aichat-create-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: #fff;
    text-decoration: none;
}

.usage-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 13px;
    margin-right: 8px;
}

.usage-badge.daily {
    background: #e3f2fd;
    color: #1976d2;
}

.usage-badge.credit {
    background: #e8f5e9;
    color: #388e3c;
}

.usage-badge.total {
    background: #fff3e0;
    color: #f57c00;
    font-weight: 600;
}

.recharge-btn {
    padding: 6px 16px;
    background: linear-gradient(135deg, #f57c00 0%, #ff9800 100%);
    color: #fff;
    border: none;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(245, 124, 0, 0.3);
}

.recharge-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.4);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    padding: 20px;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s;
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f5f5f5;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #e8e8e8;
}

.modal-body {
    padding: 24px;
}

.packages-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.package-item {
    padding: 16px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.package-item:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.package-item.selected {
    border-color: #667eea;
    background: #f0f4ff;
}

.package-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 6px;
}

.package-price {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
}

.payment-methods h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.payment-options {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.payment-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.payment-option.active {
    border-color: #667eea;
    background: #f0f4ff;
}

.payment-option input {
    display: none;
}

.payment-icon {
    font-size: 24px;
}

.recharge-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.recharge-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recharge-info li {
    padding: 6px 0;
    color: #666;
    font-size: 13px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
}

.pay-btn {
    flex: 1;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.pay-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.pay-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cancel-btn {
    padding: 12px 24px;
    background: #f5f5f5;
    color: #666;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: #e8e8e8;
}
