* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    line-height: 1.6;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px;
}

.header {
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: slideDown 0.5s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.btn-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
}

.welcome-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: fadeIn 0.6s ease;
}

.welcome-animation {
    text-align: center;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce 2s infinite;
}

.welcome-icon i {
    font-size: 2.5rem;
    color: white;
}

.welcome-text {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.student-name {
    color: var(--primary-color);
    font-weight: 700;
}

.welcome-subtitle {
    color: #666;
    font-size: 1rem;
    margin-bottom: 15px;
}

.btn-edit-name {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-edit-name:hover {
    background: var(--primary-color);
    color: white;
}

.upload-section {
    animation: fadeIn 0.8s ease;
}

.upload-card {
    background: white;
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.upload-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

.upload-icon i {
    font-size: 3rem;
    color: white;
}

.upload-card h3 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.upload-subtitle {
    color: #666;
    margin-bottom: 25px;
}

.upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 300px;
    margin: 0 auto;
}

.btn-primary, .btn-secondary, .btn-analyze, .btn-save, .btn-new {
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(33, 150, 243, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 152, 0, 0.4);
}

.preview-section, .loading-section, .result-section {
    margin-top: 20px;
}

.preview-card, .result-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: slideUp 0.4s ease;
}

#imagePreview {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 15px;
    margin-bottom: 20px;
}

.preview-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-analyze {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.btn-analyze::before {
    content: "💡 اضغط لتحليل السؤال وفهم مكوناته";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, bottom 0.3s ease;
}

.btn-analyze:hover::before {
    opacity: 1;
    bottom: calc(100% + 10px);
}

.btn-analyze:hover {
    transform: scale(1.05);
}

.btn-cancel {
    background: #f44336;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel:hover {
    background: #d32f2f;
}

.loading-section {
    background: white;
    border-radius: 20px;
    padding: 60px 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: fadeIn 0.4s ease;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    color: #666;
    font-size: 1.1rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.result-header h3 {
    color: #4CAF50;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close:hover {
    color: #333;
    transform: scale(1.2);
}

.result-content {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    text-align: right;
    line-height: 1.8;
    color: #333;
}

.result-content h4 {
    color: var(--primary-color);
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.result-content strong {
    color: var(--secondary-color);
    background: #fff3e0;
    padding: 2px 8px;
    border-radius: 5px;
}

.result-content ul {
    margin-right: 20px;
}

.result-content li {
    margin-bottom: 8px;
}

.result-tags {
    margin-bottom: 20px;
}

.result-tags label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.tag {
    padding: 8px 15px;
    border-radius: 20px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.tag:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.tag.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tag-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.tag-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.result-actions {
    display: flex;
    gap: 10px;
}

.btn-save {
    background: var(--primary-color);
    color: white;
    flex: 1;
}

.btn-save:hover {
    background: #1976D2;
}

.btn-new {
    background: var(--secondary-color);
    color: white;
    flex: 1;
}

.btn-new:hover {
    background: #F57C00;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .welcome-text {
        font-size: 1.5rem;
    }
    
    .upload-buttons {
        max-width: 100%;
    }
    
    .result-actions {
        flex-direction: column;
    }
}
