/* نظام بطاقات الشهادات القابلة للدوران - التصميم الجديد */

.clients-section {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    position: relative;
    overflow: hidden;
    padding: 6rem 0;
}

.clients-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="%23e2e8f0" stroke-width="0.5" opacity="0.3"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    pointer-events: none;
    opacity: 0.4;
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
    z-index: 3;
}

.section-title {
    background: linear-gradient(135deg, #1e293b 0%, #3b82f6 50%, #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6);
    border-radius: 2px;
}

.section-subtitle {
    font-size: 1.2rem;
    color: #475569;
    margin-top: 1.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
    font-weight: 500;
}

/* شبكة البطاقات */
.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* البطاقة القابلة للدوران */
.flip-card {
    background-color: transparent;
    width: 100%;
    height: 280px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
    transform-style: flat;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg);
    -moz-transform: rotateY(0deg);
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 20px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.08),
        0 4px 20px rgba(59, 130, 246, 0.05),
        0 2px 10px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* الوجه الأمامي - صورة العميل */
.flip-card-front {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.8) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.client-photo {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 20px;
}

.client-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    will-change: transform;
    transform: translateZ(0);
}

.flip-card:hover .client-photo img {
    transform: scale(1.05);
}

/* طبقة المعلومات على الصورة */
.photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 1.5rem 1rem 1rem;
    text-align: center;
}

.client-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    font-family: 'Cairo', sans-serif;
}

.client-position {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.flip-button {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    font-family: 'Cairo', sans-serif;
}

.flip-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

/* الوجه الخلفي - الشهادة بخلفية زرقاء */
.flip-card-back {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 50%, #1e40af 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    color: white;
}

.testimonial-content {
    text-align: center;
    width: 100%;
}

.quote-icon {
    width: 35px;
    height: 35px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 auto 1rem;
    opacity: 0.8;
}

.testimonial-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: white;
    margin-bottom: 1rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 400;
    text-align: right;
    direction: rtl;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.testimonial-text::before {
    content: '"';
    position: absolute;
    top: -10px;
    right: -5px;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.3);
    opacity: 0.5;
    font-family: serif;
}

.testimonial-text::after {
    content: '"';
    position: absolute;
    bottom: -20px;
    left: 0;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.3);
    opacity: 0.5;
    font-family: serif;
}

.testimonial-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.stars {
    color: #fbbf24;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.rating-text {
    font-weight: 600;
    color: white;
    font-size: 0.9rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.flip-back-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    font-family: 'Cairo', sans-serif;
}

.flip-back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* تأثيرات الظهور التدريجي */
.flip-card {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.flip-card:nth-child(1) {
    animation-delay: 0.1s;
}

.flip-card:nth-child(2) {
    animation-delay: 0.2s;
}

.flip-card:nth-child(3) {
    animation-delay: 0.3s;
}

.flip-card:nth-child(4) {
    animation-delay: 0.4s;
}

.flip-card:nth-child(5) {
    animation-delay: 0.5s;
}

.flip-card:nth-child(6) {
    animation-delay: 0.6s;
}

.flip-card:nth-child(7) {
    animation-delay: 0.7s;
}

.flip-card:nth-child(8) {
    animation-delay: 0.8s;
}

.flip-card:nth-child(9) {
    animation-delay: 0.9s;
}

.flip-card:nth-child(10) {
    animation-delay: 1.0s;
}

.flip-card:nth-child(11) {
    animation-delay: 1.1s;
}

.flip-card:nth-child(12) {
    animation-delay: 1.2s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px) translateZ(0);
    }

    to {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

/* إحصائيات العملاء */
.clients-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.95) 0%,
            rgba(248, 250, 252, 0.9) 50%,
            rgba(241, 245, 249, 0.85) 100%);
    padding: 4rem 3rem;
    border-radius: 32px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(59, 130, 246, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    position: relative;
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(20px);
}

.clients-stats::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg,
            #3b82f6 0%,
            #8b5cf6 25%,
            #10b981 50%,
            #f59e0b 75%,
            #3b82f6 100%);
    border-radius: 32px 32px 0 0;
}

.stat-item {
    text-align: center;
    position: relative;
}

.stat-item::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 60%;
    background: linear-gradient(to bottom, transparent, #e5e7eb, transparent);
}

.stat-item:last-child::after {
    display: none;
}

.stat-number {
    font-size: 3.5rem;
    font-weight: 900;
    background: linear-gradient(135deg,
            #1e40af 0%,
            #3b82f6 25%,
            #8b5cf6 50%,
            #3b82f6 75%,
            #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.8rem;
    line-height: 1;
    transition: transform 0.3s ease;
    position: relative;
}

/* تأثير العد التصاعدي */
.stat-number.counting {
    animation: numberPulse 0.1s ease-in-out;
}

@keyframes numberPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* تأثير الإكمال */
.stat-number.completed {
    animation: numberComplete 0.6s ease;
}

@keyframes numberComplete {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.stat-label {
    font-size: 1.1rem;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
}

.stat-label::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 1px;
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .clients-section {
        padding: 4rem 0;
    }

    .section-title {
        font-size: 2rem;
    }

    .section-subtitle {
        font-size: 1rem;
    }

    .testimonials-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.2rem;
    }

    .flip-card {
        height: 260px;
    }

    .flip-card-back {
        padding: 1.2rem;
    }

    .testimonial-text {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .client-name {
        font-size: 1rem;
    }

    .client-position {
        font-size: 0.75rem;
    }

    .clients-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        padding: 2.5rem 1.5rem;
        border-radius: 24px;
    }

    .stat-number {
        font-size: 2.8rem;
    }

    .section-header {
        margin-bottom: 3rem;
    }
}

@media (max-width: 480px) {
    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .flip-card {
        height: 240px;
    }

    .clients-stats {
        grid-template-columns: 1fr;
    }

    .stat-item::after {
        display: none;
    }

    .photo-overlay {
        padding: 0.8rem 0.6rem 0.6rem;
    }

    .flip-card-back {
        padding: 0.8rem;
    }

    .testimonial-text {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .client-name {
        font-size: 0.9rem;
    }

    .client-position {
        font-size: 0.7rem;
    }

    .flip-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }

    .flip-back-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }
}

/* تحسينات الأداء */
.flip-card {
    will-change: transform;
    backface-visibility: hidden;
    transform-origin: center center;
    isolation: isolate;
}

.flip-card-inner {
    transform-origin: center center;
    position: relative;
    z-index: 1;
}

.flip-card-front,
.flip-card-back {
    transform-origin: center center;
    top: 0;
    left: 0;
}

.client-photo img {
    will-change: transform;
}

/* إصلاح مشكلة الانزلاق أثناء الدوران */
.flip-card.flipped {
    transform: none !important;
}

.flip-card.flipped:hover {
    transform: scale(1.02) !important;
}

/* ضمان تطبيق النظام على جميع البطاقات */
.flip-card,
.flip-card * {
    box-sizing: border-box;
}

.flip-card .flip-card-inner {
    transform-origin: center center;
    backface-visibility: hidden;
}

.flip-card .flip-card-front,
.flip-card .flip-card-back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
}

/* احترام تفضيلات المستخدم لتقليل الحركة */
@media (prefers-reduced-motion: reduce) {
    .flip-card {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .flip-card:hover {
        transform: none;
    }

    .flip-card-inner {
        transition: none;
    }

    .client-photo img {
        transition: none;
    }

    .flip-button,
    .flip-back-button {
        transition: none;
    }
}

/* تأثيرات إضافية */
.flip-card:hover {
    transform: scale(1.02);
}

.flip-card.flipped:hover {
    transform: scale(1.02);
}

.flip-card:hover .flip-card-front {
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.15),
        0 10px 25px rgba(59, 130, 246, 0.1),
        0 5px 12px rgba(139, 92, 246, 0.08);
}

.flip-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg,
            rgba(59, 130, 246, 0.1),
            rgba(139, 92, 246, 0.1),
            rgba(16, 185, 129, 0.1),
            rgba(59, 130, 246, 0.1));
    border-radius: 22px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.flip-card:hover::before {
    opacity: 1;
}
