*, ::before, ::after { box-sizing: border-box; }

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap');

:root {
    --primary: #0e4834;
    --primary-light: #0e4834;
    --primary-dark: #0e4834;
    --secondary: #b9975b;
    --accent: #b9975b;
    --primary-purple: #b9975b;
    /* added for research step backgrounds */
    --bg-main: rgb(235, 230, 223);
    --bg-card: rgb(255, 255, 255);
    --text-main: rgb(64, 68, 70);
    --text-muted: rgb(160, 160, 160);
    --header-bg: #0e4834;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-home-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    z-index: 100;
}

.back-home-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.back-home-btn, .back-home-btn:visited, .back-home-btn i, .back-home-btn svg {
    color: white !important;
    stroke: white !important;
}

@media (max-width: 600px) {
    .back-home-btn {
        width: 28px !important;
        height: 28px !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
        left: auto !important;
        font-size: 0.7rem !important;
    }
}

.nav-header-btns {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    display: flex;
    gap: 10px;
    z-index: 100;
}

@media (max-width: 600px) {
    .nav-header-btns {
        top: 0.5rem !important;
        right: 0.5rem !important;
        left: auto !important;
        gap: 8px !important;
    }
    .nav-header-btns .back-home-btn {
        position: static !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 0.7rem !important;
    }
}



body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    direction: rtl;
    transition: var(--transition);
    line-height: 1.6;
}

.main-header {
    background: var(--header-bg);
    color: rgb(255, 255, 255);
    padding: 4rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    border-bottom: 1px solid var(--glass-border);
}

.main-header h1 {
    font-size: 2.5rem;
    margin: 0;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
    .main-header {
        padding: 6rem 1rem 3rem 1rem !important;
    }
    .main-header h1 {
        font-size: 1.4rem !important;
        line-height: 1.2 !important;
    }
    .main-header p {
        font-size: 0.9rem !important;
    }
}

.main-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 1rem;
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    left: 1rem;
    /* flipped for rtl */
    background: none;
    border: none;
    color: rgb(255, 255, 255);
    font-size: 1.2rem;
    cursor: pointer;
}

.container {
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.icon-box {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
    transition: var(--transition);
    animation: float 3s ease-in-out infinite;
}

.card:hover .icon-box {
    transform: rotate(10deg) scale(1.1);
    animation: float 1s ease-in-out infinite;
}

.blue-icon {
    background: rgba(14, 72, 52, 0.1);
    color: var(--primary);
}

.green-icon {
    background: rgba(14, 72, 52, 0.1);
    color: var(--secondary);
}

.btn {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background-color: var(--primary);
    color: rgb(255, 255, 255);
}

/* ensure the outline button stays legible when pressed or focused */
.btn-outline:active,
.btn-outline:focus {
    background-color: var(--primary);
    color: rgb(255, 255, 255);
    outline: none;
}

/* keep visited links same color to avoid unreadable text */
.btn-outline:visited {
    color: var(--primary);
}

.btn-solid {
    background: var(--secondary);
    color: rgb(255, 255, 255);
    box-shadow: 0 4px 14px 0 rgba(14, 72, 52, 0.39);
}

.btn-solid:hover {
    background: #0e4834;
    box-shadow: 0 6px 20px rgba(14, 72, 52, 0.23);
    transform: translateY(-2px);
}

/* تنسيق ذيل الصفحة */
.main-footer {
    text-align: center;
    padding: 2rem;
    color: rgb(160, 160, 160);
    font-size: 0.875rem;
    margin-top: 2rem;
}

.volet-card {
    display: none;
    animation: slideUp 0.5s ease-out;
}

.volet-card.active {
    display: block !important;

}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-container {
    max-width: 950px;
    margin: 20px auto;
    padding: 0 1rem;
}

.volet-header {
    padding: 3rem 1.5rem;
    color: rgb(255, 255, 255);
    text-align: center;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: 2rem;
}

.header-v1 {
    background: #0e4834;
}

.header-v2 {
    background: #0e4834;
}

.header-total {
    background: linear-gradient(135deg, rgb(100, 100, 100), rgb(183, 183, 183));
}

.section-header {
    padding: 0 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    border-right: 4px solid var(--primary);
    padding-right: 1rem;
    font-size: 1.5rem;
    color: var(--text-main);
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

.result-bar {
    background: var(--bg-card);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    margin-top: 2rem;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

/*  التنقل بين المحورين */

.stepper {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    background: rgb(234, 234, 234);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid rgb(234, 234, 234);
}

.step {
    padding: 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
    text-align: center;
}

.step.active-v1 {
    background: var(--primary);
    color: rgb(255, 255, 255);
    box-shadow: 0 4px 12px rgba(14, 72, 52, 0.3);
}

.step.active-v2 {
    background: var(--primary-purple);
    color: rgb(255, 255, 255);
    box-shadow: 0 4px 12px rgba(14, 72, 52, 0.3);
}

.input-box {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.input-box:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}


.total-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: rgb(255, 255, 255) !important;
    padding: 1.2rem 2.5rem;
    border-radius: 9999px;
    font-size: 1.5rem;
    font-weight: 800;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    min-width: 200px;
    justify-content: center;
}

.badge-v1 {
    background: #0e4834 !important;
}

.badge-v2 {
    background: #b9975b !important;
    color: rgb(64, 68, 70) !important;
}

.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    transition: all 0.2s;
    font-size: 1.1rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgb(255, 255, 255) !important;
}

.btn-blue {
    background: #0e4834 !important;
}

.btn-purple {
    background: #b9975b !important;
    color: rgb(64, 68, 70) !important;
}

.btn-gray {
    background: rgb(160, 160, 160) !important;
}

.btn-green {
    background: #0e4834 !important;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* بوتونز */
.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.nav-buttons.mt-30 {
    margin-top: 30px;
}

/* utility margins */
.mb-20 {
    margin-bottom: 20px;
}

.btn {
    padding: 14px 35px;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.95rem;
}

.btn-blue {
    background: var(--primary-gray);
    color: rgb(255, 255, 255);
}

.btn-purple {
    background: var(--primary-purple);
    color: rgb(255, 255, 255);
}

.btn-gray {
    background: var(--primary-gray);
    color: rgb(255, 255, 255);
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}


.final-summary {
    padding: 50px 30px;
    text-align: center;
}

/* .summary-item { font-size: 1.15rem; margin: 15px 0; color: rgb(160, 160, 160); }
    .summary-item b { font-size: 1.6rem; color: rgb(64, 68, 70); }*/
.final-total-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-gray);
    margin-top: 20px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.final-total {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-gray);
    background: var(--bg-gray);
    padding: 20px;
    border-radius: 15px;
    margin: 0 30px;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === تحسين Animations للانتقال بين الأقسام === */

/* Slide In from Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide In from Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide Up */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse for active step */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(14, 72, 52, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(14, 72, 52, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(14, 72, 52, 0);
    }
}

/* Bounce for buttons */
@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }

    60% {
        transform: translateY(-3px);
    }
}

/* Glow effect for total score */
@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(14, 72, 52, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(14, 72, 52, 0.6);
    }

    100% {
        box-shadow: 0 0 5px rgba(14, 72, 52, 0.3);
    }
}

/* Shake for error */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* Float animation for icons */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

/* === Applied Animations === */

.volet-card.active {
    animation: slideUp 0.5s ease-out, fadeIn 0.5s ease-out;
}

.step.active-v1,
.step.active-v2,
.step.active-total {
    animation: pulse 2s infinite, scaleIn 0.3s ease-out;
}

.total-badge {
    animation: glow 2s ease-in-out infinite;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.total-badge.updated {
    animation: pulse 0.5s ease-out;
}

.btn:hover {
    animation: bounce 0.5s ease;
}

.input-box {
    transition: all 0.3s ease;
}

.input-box:focus-within {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(14, 72, 52, 0.2);
}

/* Staggered animation for input boxes */
.grid-layout .input-box:nth-child(1) {
    animation-delay: 0.05s;
}

.grid-layout .input-box:nth-child(2) {
    animation-delay: 0.1s;
}

.grid-layout .input-box:nth-child(3) {
    animation-delay: 0.15s;
}

.grid-layout .input-box:nth-child(4) {
    animation-delay: 0.2s;
}

.grid-layout .input-box:nth-child(5) {
    animation-delay: 0.25s;
}

.grid-layout .input-box:nth-child(6) {
    animation-delay: 0.3s;
}

.grid-layout .input-box:nth-child(7) {
    animation-delay: 0.35s;
}

.grid-layout .input-box:nth-child(8) {
    animation-delay: 0.4s;
}

.grid-layout .input-box {
    animation: fadeIn 0.4s ease-out backwards;
}

/* Section headers animation */
.section-header {
    animation: slideInRight 0.5s ease-out;
}

.volet-header {
    animation: scaleIn 0.6s ease-out;
}

/* Result bar animation */
.result-bar {
    animation: slideUp 0.5s ease-out 0.3s backwards;
}


.input-box input,
.input-box select {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 1px solid rgb(183, 183, 183);
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
    box-sizing: border-box;
    background: rgb(255, 255, 255);
    color: rgb(64, 68, 70);
}

/* إزالة الأسهم في Chrome, Edge, Safari */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* إزالة الأسهم في Firefox */
input[type=number] {
    -webkit-appearance: textfield;
    appearance: textfield;
}

.error-msg {
    display: block;
    color: #b9975b;
    font-size: 0.75rem;
    margin-top: 4px;
    min-height: 1em;
}

.section-title-blue {
    color: #0e4834;
    border-color: #0e4834;
}

.section-title-red {
    color: #b9975b;
    border-color: #b9975b;
}

.grid-full {
    grid-column: 1/-1;
    display: flex;
    justify-content: space-around;
    background: var(--bg-gray);
    padding: 15px;
    border-radius: 10px;
}

.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.modal-content {
    background-color: rgb(255, 255, 255);
    margin: 2% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 550px;
    direction: rtl;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    background-color: #0e4834;
    color: rgb(255, 255, 255);
    padding: 15px;
    text-align: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-body {
    padding: 20px 30px;
    color: rgb(64, 68, 70);
    line-height: 1.6;
}

.modal-body p {
    font-weight: bold;
    font-size: 15px;
    color: rgb(64, 68, 70);
    margin-bottom: 10px;
}

.modal-info {
    background: rgb(234, 234, 234);
    padding: 12px;
    border-right: 5px solid #0e4834;
}

.modal-footer {
    padding: 15px;
    text-align: center;
    background: rgb(234, 234, 234);
}

.modal-btn {
    background-color: #0e4834;
    color: rgb(255, 255, 255);
    border: none;
    padding: 10px 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: 0.3s;
}

/* utility classes */
.rtl {
    text-align: right;
}

.accent-blue {
    border-right: 5px solid var(--primary-blue);
}

.accent-green {
    border-right: 5px solid #0e4834;
}

.accent-orange {
    border-right: 5px solid #b9975b;
}

.accent-bottom-blue {
    border-bottom: 4px solid var(--primary-blue);
}

.no-style {
    list-style: none;
    padding: 0;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}



/*+++++*/
.card a.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    text-align: center;
}

/* responsive improvements */
@media (max-width: 600px) {
    .main-header {
        padding: 2rem 1rem;
    }

    .main-header h1 {
        font-size: 1.6rem;
    }

    .main-header p {
        font-size: 0.95rem;
    }

    .container {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    .cards-grid {
        gap: 1.25rem;
    }

    .card {
        padding: 1.5rem;
    }

    .stepper {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.25rem;
    }

    .step {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .total-badge {
        font-size: 1.1rem;
        padding: 0.8rem 1.5rem;
        min-width: 150px;
    }

    .final-total {
        font-size: 1.6rem;
        padding: 12px;
        margin: 0 5px;
    }

    .volet-header {
        padding: 1.5rem 1rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    .grid-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
}

/* hide print-only elements when viewing on screen */
@media screen {
    .print-only {
        display: none !important;
    }
}

/* 1. في الحالة العادية: التقرير مخفي تماماً ولا يحجز مساحة */
.print-only {
    display: none !important;
}

/* --- الحالة العادية (المتصفح) --- */
.print-only {
    display: none !important;
    /* إخفاء تام عن الشاشة */
}

/* --- حالة الطباعة --- */
/* الحالة العادية */
.print-only {
    display: none !important;
}

@media print {

    /* 1. إخفاء كل شيء باستخدام visibility لضمان عدم حدوث مشاكل في التداخل */
    body * {
        visibility: hidden !important;
    }

    /* 2. إظهار التقرير وأبنائه فقط */
    #print-report,
    #print-report * {
        visibility: visible !important;
    }

    /* 3. تنسيق التقرير كعنصر أساسي في الصفحة */
    #print-report {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        width: 100% !important;
        padding: 60px 80px !important;
        direction: rtl !important;
        box-sizing: border-box !important;
        margin: 0 auto !important;
        text-align: right !important;
        background: white !important;
    }

    /* 4. إلغاء هوامش الصفحة لإخفاء الروابط التلقائية */
    @page {
        size: A4;
        margin: 0 !important;
    }

    /* 5. تحسين شكل العناصر في الطباعة */
    .report-grid {
        display: flex !important;
        gap: 15px !important;
        margin: 20px 0 !important;
    }

    .report-box {
        flex: 1 !important;
        border: 1px solid rgb(64, 68, 70) !important;
        padding: 10px !important;
    }

    .report-total-box {
        border: 2px solid rgb(64, 68, 70) !important;
        background-color: rgb(234, 234, 234) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        margin-top: 20px !important;
        padding: 15px !important;
        text-align: center !important;
    }

    .report-title {
        text-align: center !important;
        font-size: 22px !important;
        margin-bottom: 10px !important;
    }

    .report-hr {
        border: 1px solid #ccc !important;
        margin-bottom: 20px !important;
    }

    .report-footer {
        text-align: center !important;
        margin-top: 50px !important;
        font-size: 12px !important;
    }
}