html, body {
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

* {
    box-sizing: border-box;
}

.wrapper {
    max-width: 900px;
    width: 100%;
    margin: 30px auto;
    padding: 0 15px;
    box-sizing: border-box;
}

.app {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

/* ===== الترويسة ===== */
.header {
    padding: 30px 25px 20px;
    background: 
        radial-gradient(circle at top right, rgba(78,205,196,0.15), transparent),
        radial-gradient(circle at bottom left, rgba(125,60,152,0.15), transparent),
        linear-gradient(180deg, #ffffff, #f8fafb);
    border-bottom: 2px solid #e8eef5;
    width: 100%;
}

.title {
    margin-bottom: 25px;
    width: 100%;
}

.heading {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 800;
    color: #7D3C98;
    margin-bottom: 8px;
    text-align: center;
}

.subtitle {
    color: #606571;
    font-size: clamp(0.9rem, 2vw, 1rem);
    text-align: center;
    line-height: 1.5;
}

/* ===== شريط التقدم ===== */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 10px;
}

.progress {
    position: relative;
    flex: 1;
    height: 12px;
    background: #e8eef5;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid #d1d5db;
}

.progress #bar {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4ECDC4, #7D3C98);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s ease;
    will-change: transform;
    display: block;
    -webkit-transform: scaleX(0);
    -webkit-transform-origin: right;
    -webkit-transition: transform 0.4s ease;
}
#progresstext {
    color: #6b7280;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    font-weight: 600;
    min-width: 90px;
    white-space: nowrap;
    text-align: left;
}

/* ===== المحتوى ===== */
.content {
    padding: 25px;
    width: 100%;
    box-sizing: border-box;
}

.question {
    background: #f8fafb;
    border: 2px solid #e8eef5;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.question:hover,
.question:focus-within {
    background: #ffffff;
    border-color: #4ECDC4;
    box-shadow: 0 4px 15px rgba(78,205,196,0.15);
}

.question legend {
    position: absolute;
    left: -9999px;
}

.question h3 {
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 15px;
    line-height: 1.6;
}

/* ===== الخيارات ===== */
.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border: 2px solid #e8eef5;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
}

.option:hover {
    border-color: #4ECDC4;
    background: #f0fffe;
}

.option input[type="radio"] {
    appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    border: 2px solid #7D3C98;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.option input[type="radio"]:checked {
    border-color: #4ECDC4;
    box-shadow: 0 0 0 4px rgba(78,205,196,0.2);
}

.option input[type="radio"]::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.2s ease;
    background: linear-gradient(135deg, #4ECDC4, #7D3C98);
}

.option input[type="radio"]:checked::before {
    transform: scale(1);
}

.option span {
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    color: #374151;
    font-weight: 500;
    flex: 1;
}

/* ===== النص المفتوح ===== */
.open-text {
    background: #ffffff;
    border-color: #d1d5db;
}

.open-text textarea {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    border: 2px solid #e8eef5;
    border-radius: 12px;
    font-family: inherit;
    font-size: clamp(0.9rem, 2vw, 0.95rem);
    resize: vertical;
    min-height: 120px;
    transition: all 0.2s ease;
    line-height: 1.6;
    box-sizing: border-box;
}

.open-text textarea:focus {
    outline: none;
    border-color: #4ECDC4;
    box-shadow: 0 0 0 4px rgba(78,205,196,0.1);
}

.open-text textarea::placeholder {
    color: #9ca3af;
}

/* ===== التذييل ===== */
.footer {
    padding: 20px 25px;
    border-top: 2px solid #e8eef5;
    background: #f8fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.actions-left,
.actions-right {
    display: flex;
    gap: 10px;
}

.btn {
    border: 0;
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #7D3C98, #4ECDC4);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(125,60,152,0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #8e44ad, #5ddbd3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(125,60,152,0.4);
}

.btn-ghost {
    background: #ffffff;
    border: 2px solid #e8eef5;
    color: #6b7280;
}

.btn-ghost:hover {
    border-color: #7D3C98;
    color: #7D3C98;
    background: #f8fafb;
}

/* ===== Notification System ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    background: #ffffff;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 99999;
    transform: translateX(450px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 420px;
    border-right: 5px solid #7D3C98;
    pointer-events: auto;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iconPop {
    0% { 
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% { 
        transform: scale(1.2) rotate(10deg);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.notification-text {
    font-size: 0.95rem;
    color: #374151;
    font-weight: 600;
    line-height: 1.5;
}

.notification-error {
    border-right-color: #ef4444;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}

.notification-error .notification-icon {
    color: #ef4444;
}

.notification-success {
    border-right-color: #10b981;
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}

.notification-success .notification-icon {
    color: #10b981;
}

.notification-info {
    border-right-color: #3b82f6;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
}

.notification-info .notification-icon {
    color: #3b82f6;
}

/* ===== صندوق التأكيد ===== */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.confirm-overlay.show {
    opacity: 1;
}

.confirm-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin: 0 auto;
    position: relative;
    text-align: center;
}

.confirm-overlay.show .confirm-box {
    transform: scale(1);
}

.confirm-box h3 {
    font-size: 1.3rem;
    color: #7D3C98;
    margin-bottom: 12px;
    font-weight: 800;
}

.confirm-box p {
    font-size: 1rem;
    color: #4b5563;
    margin-bottom: 24px;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.confirm-actions .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    min-width: 100px;
}

/* ===== Loading Spinner ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 480px) {
    .wrapper {
        margin: 10px auto;
        padding: 0 10px;
    }
    
    .app {
        border-radius: 12px;
    }
    
    .question h3 {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .actions-left, .actions-right {
        width: 100%;
    }
    
    .actions-left .btn, .actions-right .btn {
        width: 100%;
    }
}
@media (max-width: 640px) {
    .wrapper {
        margin: 15px auto;
        padding: 0 10px;
        width: calc(100% - 20px);
    }

    .app {
        border-radius: 16px;
    }

    .header {
        padding: 20px 15px;
    }

    .heading {
        font-size: 1.2rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .progress {
        height: 10px;
        border: 2px solid #d1d5db;
    }
    
    .progress-container {
        flex-direction: row;
        gap: 10px;
    }

    #progresstext {
        text-align: right;
        font-size: 0.85rem;
        min-width: 80px;
    }

    .content {
        padding: 15px;
    }

    .question {
        padding: 14px;
        margin-bottom: 15px;
    }

    .question h3 {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    .option {
        padding: 10px 12px;
        gap: 10px;
    }

    .option span {
        font-size: 0.85rem;
    }

    .open-text textarea {
        font-size: 0.9rem;
        padding: 12px;
        min-height: 100px;
    }

    .footer {
        flex-direction: column;
        padding: 15px;
        gap: 10px;
    }

    .actions-left,
    .actions-right {
        width: 100%;
        justify-content: center;
    }

    .btn {
        flex: 1;
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 14px 18px;
        border-radius: 12px;
        transform: translateY(-150px) scale(0.9);
        box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    }
    
    .notification.show {
        transform: translateY(0) scale(1);
    }
    
    .notification-icon {
        font-size: 1.4rem;
    }
    
    .notification-text {
        font-size: 0.9rem;
    }

    .confirm-overlay {
        padding: 15px;
    }

    .confirm-box {
        padding: 25px 20px;
        width: 95%;
        max-width: none;
    }
    
    .confirm-box h3 {
        font-size: 1.2rem;
    }
    
    .confirm-box p {
        font-size: 0.95rem;
        margin-bottom: 20px;
    }
    
    .confirm-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .confirm-actions .btn {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .wrapper {
        padding: 0 8px;
        width: calc(100% - 16px);
    }

    .heading {
        font-size: 1.1rem;
    }

    .question h3 {
        font-size: 0.85rem;
    }

    .option {
        padding: 8px 10px;
    }

    .option span {
        font-size: 0.8rem;
    }

    .option input[type="radio"] {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
    }

    .btn {
        font-size: 0.85rem;
        padding: 10px 14px;
    }

    .notification {
        padding: 12px 16px;
        top: 8px;
        right: 8px;
        left: 8px;
    }
    
    .notification-icon {
        font-size: 1.3rem;
    }
    
    .notification-text {
        font-size: 0.85rem;
    }

    .confirm-box {
        padding: 20px 15px;
        width: 96%;
    }
}

@media (max-width: 320px) {
    .wrapper {
        padding: 0 5px;
        width: calc(100% - 10px);
    }

    .question {
        padding: 12px;
    }

    .question h3 {
        font-size: 0.8rem;
    }

    .notification {
        padding: 10px 14px;
    }
}
@media (max-width: 768px) {
    .progress-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .progress {
        order: 1;
    }
    
    #progresstext {
        order: 2;
        text-align: center !important;
        min-width: auto;
    }
    
    .header {
        padding: 20px 15px;
    }
    
    .content {
        padding: 15px;
    }
    
    .question {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    /* تحسين الخيارات للشاشات الصغيرة */
    .option {
        padding: 10px 12px;
    }
    
    .option span {
        font-size: 0.85rem;
    }
}