* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f0f4f0 0%, #e6efe6 100%);
    min-height: 100vh;
    color: #1a1a1a;
    direction: rtl;
    padding: 16px;
}

/* ======================================
   الكونتينر الرئيسي للنموذج
   ====================================== */
.form-container {
    max-width: 980px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(23, 131, 82, 0.12);
    overflow: hidden;
}

/* ======================================
   الهيدر العلوي
   ====================================== */
.form-header {
    background: linear-gradient(90deg, #178352 0%, #0f7a49 100%);
    padding: 28px 32px;
    text-align: center;
}

.header-logos {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.header-logo {
    height: 75px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 10px;
    padding: 6px;
}

.header-logo-tanzeem {
    height: 80px;
}

.form-main-title {
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.form-subtitle {
    color: #d4ecd8;
    font-size: 15px;
    font-weight: 500;
}

/* ======================================
   الفورم والكروت
   ====================================== */
.cert-form {
    padding: 28px 32px;
}

.form-section-card {
    background: #f9faf9;
    border: 1px solid #e5ece5;
    border-radius: 14px;
    padding: 20px 22px;
    margin-bottom: 22px;
}

.form-section-title {
    color: #178352;
    font-size: 17px;
    font-weight: 700;
    padding-bottom: 12px;
    margin-bottom: 18px;
    border-bottom: 2px solid #c6e0c9;
}

/* ======================================
   الجريد (الشبكة) للحقول
   ====================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 7px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d0d9d0;
    border-radius: 9px;
    background: #ffffff;
    font-size: 15px;
    font-family: inherit;
    color: #222;
    transition: all 0.2s ease;
    direction: rtl;
    text-align: right;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #178352;
    box-shadow: 0 0 0 3px rgba(23, 131, 82, 0.12);
    background: #fafffa;
}

.form-field textarea {
    resize: vertical;
    min-height: 70px;
}

/* ======================================
   أعضاء مجلس الإدارة - الإدخال اليدوي
   ====================================== */
.board-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.board-member-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #d0d9d0;
    border-radius: 9px;
    background: #ffffff;
    font-size: 15px;
    font-family: inherit;
    color: #222;
    transition: all 0.2s ease;
    direction: rtl;
    text-align: right;
}

.board-member-input:focus {
    outline: none;
    border-color: #178352;
    box-shadow: 0 0 0 3px rgba(23, 131, 82, 0.12);
    background: #fafffa;
}

.btn-remove-member {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 9px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-remove-member:hover:not(:disabled) {
    background: #ef4444;
    color: #fff;
    transform: scale(1.05);
}

.btn-remove-member:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.btn-add-member {
    margin-top: 8px;
    width: 100%;
    padding: 11px 18px;
    border: 2px dashed #178352;
    border-radius: 10px;
    background: #f0fbf3;
    color: #0f7a49;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-member:hover {
    background: #178352;
    color: #fff;
    border-style: solid;
    transform: translateY(-1px);
}

/* ======================================
   زر الحفظ
   ====================================== */
.form-actions {
    text-align: center;
    margin: 32px 0 12px 0;
}

.btn-save {
    background: linear-gradient(135deg, #178352 0%, #129259 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 15px 48px;
    font-size: 17px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 18px rgba(23, 131, 82, 0.22);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(23, 131, 82, 0.32);
}

.btn-save:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 19px;
}

/* ======================================
   قسم عرض النتيجة + الـ QR
   ====================================== */
.qr-result-section {
    margin-top: 36px;
    padding: 26px 28px;
    background: linear-gradient(135deg, #f0fbf3 0%, #e5f7eb 100%);
    border: 2px solid #b8e2c0;
    border-radius: 16px;
}

.qr-success-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.success-icon {
    font-size: 34px;
}

.qr-success-header h3 {
    color: #0f7a49;
    font-size: 20px;
    font-weight: 700;
}

.qr-desc {
    text-align: center;
    color: #444;
    font-size: 14px;
    margin-bottom: 22px;
}

.qr-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    border: 1px dashed #a5d3ae;
    flex-wrap: wrap;
}

.qr-code-image {
    width: 220px;
    height: 220px;
    border-radius: 10px;
    padding: 12px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.qr-info {
    text-align: right;
    max-width: 340px;
    flex: 1;
    min-width: 260px;
}

.qr-url-label {
    color: #666;
    font-size: 13px;
    margin-bottom: 6px;
}

.qr-url {
    color: #178352;
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
    padding: 10px 14px;
    background: #f5faf5;
    border-radius: 8px;
    margin-bottom: 16px;
    direction: ltr;
    text-align: left;
}

.btn-open-cert {
    display: inline-block;
    background: #0d4d4d;
    color: #fff;
    text-decoration: none;
    padding: 11px 24px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-open-cert:hover {
    background: #0a4242;
    transform: translateY(-1px);
}

/* ======================================
          ========== أجهزة الموبايل ==========
   ====================================== */

/* --- Medium Phone (iPhone 12/13/14, Galaxy S21/S22 - عرض حتى 767px) --- */
@media (max-width: 767px) {
    body {
        padding: 10px;
    }

    .form-header {
        padding: 20px 18px;
    }

    .header-logos {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 14px;
    }

    .header-logo {
        height: 55px !important;
    }

    .form-main-title {
        font-size: 17px;
        line-height: 1.4;
    }

    .form-subtitle {
        font-size: 13px;
    }

    .cert-form {
        padding: 18px 16px;
    }

    .form-section-card {
        padding: 16px 14px;
        border-radius: 12px;
        margin-bottom: 18px;
    }

    .form-section-title {
        font-size: 15px;
        padding-bottom: 10px;
        margin-bottom: 14px;
    }

    /* الجريد يبقى عمود واحد على الموبايل */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .form-field input,
    .form-field select,
    .form-field textarea {
        padding: 12px 14px;
        font-size: 16px; /* لمنع التكبير التلقائي على iPhone */
    }

    .btn-save {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 16px;
    }

    .qr-result-section {
        margin-top: 28px;
        padding: 20px 16px;
    }

    .success-icon {
        font-size: 28px;
    }

    .qr-success-header h3 {
        font-size: 16px;
    }

    .qr-wrapper {
        flex-direction: column;
        gap: 20px;
        padding: 18px 14px;
    }

    .qr-code-image {
        width: 180px;
        height: 180px;
    }

    .qr-info {
        text-align: center;
        min-width: 0;
        width: 100%;
    }

    .qr-url {
        text-align: center;
        font-size: 13px;
    }

    .btn-open-cert {
        width: 100%;
        text-align: center;
    }
}

/* --- Small Phone (iPhone SE/8, قديمات أندروميد - عرض حتى 480px) --- */
@media (max-width: 480px) {
    body {
        padding: 6px;
    }

    .form-container {
        border-radius: 14px;
    }

    .form-header {
        padding: 16px 12px;
    }

    .header-logo {
        height: 45px !important;
    }

    .form-main-title {
        font-size: 15px;
    }

    .form-subtitle {
        font-size: 12px;
    }

    .cert-form {
        padding: 14px 12px;
    }

    .form-section-card {
        padding: 14px 12px;
        margin-bottom: 14px;
    }

    .form-section-title {
        font-size: 14px;
    }

    .form-field label {
        font-size: 12px;
    }

    .qr-code-image {
        width: 150px;
        height: 150px;
    }

    .board-member-row {
        flex-direction: row;
        gap: 6px;
    }

    .btn-remove-member {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .btn-add-member {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* --- Large Phone / Small Tablet (Galaxy Fold مفتوح, iPad Mini - 768 إلى 1024px) --- */
@media (min-width: 768px) and (max-width: 1024px) {
    .cert-form {
        padding: 22px 20px;
    }

    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px 16px;
    }

    .qr-wrapper {
        gap: 24px;
    }
}
