:root {
    --gov-green: #0f9d58;
    --gov-dark-green: #0b8043;
    --gov-light-green: #e6f4ea;
    --border-green: #b7dfc5;
    --text-dark: #1f2937;
    --text-white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Font Face Placeholder */
@font-face {
    font-family: 'Noori Nastaleeq';
    src: url('../fonts/noori-nastaleeq.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* Main Container - EXPLICIT ID + CLASS */
#e8171-wrapper,
.e8171-container {
    width: 1200px !important;
    /* Force 1200px width */
    max-width: 95vw;
    /* Responsive cutoff */
    margin: 2rem auto;
    background: #ffffff;
    padding: 3rem;
    /* 48px padding -> 1200 - 96 = 1104px content area */
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border-top: 6px solid var(--gov-green);
    font-family: 'Arial', sans-serif;
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.e8171-container * {
    box-sizing: border-box;
}

/* RTL Support */
.rtl .e8171-container {
    direction: rtl;
    font-family: 'Noori Nastaleeq', 'Arial', serif;
}

/* Grid Layout - FORCE 2 COLUMNS */
.e8171-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    /* 2 columns on large screens */
    gap: 2rem;
    /* 32px gap. Content 1104 - 32 = 1072. Each col = 536px */
    margin-bottom: 2rem;
    width: 100%;
}

@media (max-width: 768px) {

    /* User requested: 2-column layout on screens larger than 768px */
    .e8171-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    .e8171-container,
    #e8171-wrapper {
        padding: 2rem;
        width: 95% !important;
        /* Fluid on mobile */
    }
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Language Toggle */
.e8171-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2rem;
}

.e8171-lang-toggle {
    display: flex;
    border: 1px solid var(--gov-green);
    border-radius: 6px;
    overflow: hidden;
}

.btn-lang {
    background: #fff;
    color: var(--gov-green);
    border: none;
    padding: 10px 24px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    /* Explicit 16px */
    transition: all 0.3s ease;
}

.btn-lang:hover:not(.active) {
    background-color: var(--gov-light-green);
    color: var(--gov-dark-green);
}

.btn-lang.active {
    background: var(--gov-green);
    color: #fff;
}

/* Form Styles */
h2 {
    text-align: center;
    color: var(--gov-green);
    margin-bottom: 2.5rem;
    font-size: 2rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 0;
    /* Handled by grid gap */
    position: relative;
    display: flex;
    flex-direction: column;
}

label {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #374151;
    font-size: 16px;
}

input[type="text"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-green);
    border-radius: 6px;
    font-size: 16px;
    background: #fdfdfd;
    transition: border-color 0.6s ease, box-shadow 0.6s ease, background-color 0.6s ease;
    /* Slower transition */
}

input:focus,
select:focus {
    border-color: var(--gov-green);
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 4px var(--gov-light-green);
    transform: translateY(-1px);
}

/* Checkbox Groups */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 10px 0;
}

.checkbox-group label {
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: #f9fafb;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.checkbox-group label:hover {
    background: var(--gov-light-green);
    border-color: var(--border-green);
}

.checkbox-group input[type="checkbox"] {
    accent-color: var(--gov-green);
}

/* Tooltip */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background-color: var(--gov-green);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
    cursor: help;
    box-shadow: 0 2px 4px rgba(15, 157, 88, 0.3);
    font-style: normal;
}

.form-text {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

/* Submit Button */
.e8171-submit {
    width: 100%;
    max-width: 300px;
    margin: 3rem auto 0;
    display: block;
    background: var(--gov-green);
    color: white;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(15, 157, 88, 0.4);
}

.e8171-submit:hover {
    background: var(--gov-dark-green);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(15, 157, 88, 0.5);
}

.e8171-submit:active {
    transform: translateY(0);
}

.e8171-footer {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.9rem;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
}

/* Modal Styles Refined */
.e8171-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.e8171-modal.show {
    opacity: 1;
}

/* Backdrop Blur */
.e8171-modal-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.e8171-modal-content {
    background-color: #fff;
    margin: 5% auto;
    /* Adjusted for better vertical centering view */
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    position: relative;
    border-top: none;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.e8171-modal.show .e8171-modal-content {
    transform: scale(1);
}

.close-modal-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #9ca3af;
    font-size: 24px;
    font-weight: normal;
    background: #f3f4f6;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    z-index: 10;
}

/* RTL Close Icon Position */
.rtl .close-modal-icon {
    right: auto;
    left: 15px;
}

.close-modal-icon:hover {
    color: var(--text-dark);
    background: #e5e7eb;
    transform: rotate(90deg);
}

.modal-body {
    padding: 2.5rem;
}

.modal-header-icon {
    text-align: center;
    font-size: 4rem;
    margin: 2rem 0 1rem;
    line-height: 1;
}

#modal-result-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

#modal-message {
    text-align: center;
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.e8171-reasons,
.e8171-next-steps {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.e8171-reasons h4,
.e8171-next-steps h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.e8171-reasons ul,
.e8171-next-steps p {
    margin-bottom: 0.5rem;
    color: #4b5563;
    line-height: 1.6;
}

.e8171-reasons ul {
    padding-left: 1.5rem;
}

/* Result specific colors/styles */
.result-eligible {
    color: var(--gov-green);
}

.result-action {
    color: #f59e0b;
}

.result-not-eligible {
    color: #ef4444;
}

/* Responsive Modal */
@media (max-width: 600px) {
    .e8171-modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .modal-body {
        padding: 1.5rem;
    }
}