:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
    --primary-color: #2481cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    direction: rtl;
    overflow-x: hidden;
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--tg-theme-bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* App Container */
.app-container {
    min-height: 100vh;
    padding-bottom: 80px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #1a5a8c);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.app-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.user-info {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.user-name {
    font-weight: 500;
}

.user-status {
    padding: 0.2rem 0.5rem;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Navigation */
.nav-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 99;
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    border: none;
    background: none;
    color: var(--tg-theme-hint-color);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 8px;
}

.nav-tab.active {
    color: var(--primary-color);
    background: rgba(36, 129, 204, 0.1);
}

.nav-icon {
    font-size: 1.5rem;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

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

/* Welcome Card */
.welcome-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.welcome-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.welcome-text {
    font-size: 0.95rem;
    opacity: 0.95;
    line-height: 1.6;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.feature-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.feature-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--tg-theme-hint-color);
}

/* Stats Card */
.stats-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.stats-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--tg-theme-hint-color);
    margin-top: 0.25rem;
}

/* Quick Actions */
.quick-actions {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.quick-actions h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.action-btn {
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.action-btn.primary:hover {
    background: #1a5a8c;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: var(--light-bg);
    color: var(--primary-color);
}

.action-btn.secondary:hover {
    background: #e2e6ea;
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Projects */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tab-header h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.btn-create {
    padding: 0.6rem 1.2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-create:hover {
    background: #1a5a8c;
}

.projects-list {
    display: grid;
    gap: 1rem;
}

.project-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.project-card h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.project-card p {
    font-size: 0.9rem;
    color: var(--tg-theme-hint-color);
    margin-bottom: 0.75rem;
}

.project-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--tg-theme-hint-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--light-bg);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--tg-theme-hint-color);
}

.btn-close:hover {
    background: var(--border-color);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--tg-theme-text-color);
}

.form-input, .form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-textarea.code-textarea {
    font-family: 'Courier New', monospace;
    min-height: 200px;
}

.form-textarea.editor-large {
    min-height: 400px;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-cancel, .btn-save {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-cancel {
    background: var(--light-bg);
    color: var(--tg-theme-text-color);
}

.btn-cancel:hover {
    background: var(--border-color);
}

.btn-save {
    background: var(--primary-color);
    color: white;
}

.btn-save:hover {
    background: #1a5a8c;
}

/* Chat */
.chat-container {
    background: white;
    border-radius: 16px;
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.btn-clear-chat {
    padding: 0.5rem 1rem;
    background: var(--light-bg);
    border: none;
    border-radius: 6px;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 0.9rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-welcome {
    text-align: center;
    padding: 2rem;
    color: var(--tg-theme-hint-color);
}

.chat-welcome-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.chat-help-text {
    margin-top: 1rem;
    font-size: 0.9rem;
    line-height: 1.8;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message-content {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
}

.chat-message.user .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.ai .message-content {
    background: var(--light-bg);
    color: var(--tg-theme-text-color);
    border-bottom-left-radius: 4px;
}

.chat-input-container {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 100px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: #1a5a8c;
}

/* Subscription */
.subscription-container {
    max-width: 600px;
    margin: 0 auto;
}

.subscription-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 1.5rem;
}

.subscription-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.subscription-status {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.subscription-benefits {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.subscription-benefits h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.benefits-list {
    display: grid;
    gap: 0.75rem;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
}

.benefit-icon {
    font-size: 1.2rem;
}

.subscription-plans {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.plan-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
}

.plan-card.featured {
    border: 2px solid var(--primary-color);
}

.plan-badge {
    position: absolute;
    top: -10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.plan-card h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.plan-price {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.plan-duration {
    font-size: 0.9rem;
    color: var(--tg-theme-hint-color);
    margin-bottom: 1rem;
}

.btn-subscribe {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-subscribe:hover {
    background: #1a5a8c;
}

.referral-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.referral-section h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.referral-link {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.referral-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
}

.btn-copy {
    padding: 0.75rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-copy:hover {
    background: #1a5a8c;
}

/* Responsive */
@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .subscription-plans {
        grid-template-columns: 1fr;
    }
    
    .modal-content.modal-large {
        max-width: 100%;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--tg-theme-hint-color);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--tg-theme-hint-color);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 2000;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        bottom: 80px;
        opacity: 0;
    }
    to {
        bottom: 100px;
        opacity: 1;
    }
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
    color: #000;
}
