/* ============================================================
   حاسبة الطاقة الشمسية - تصميم متجاوب (موبايل → شاشات 98")
   لا تغيير في لون الخلفية الأساسي - فقط تحسين الوضوح والتنظيم
   ============================================================ */

:root {
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 6px 24px rgba(0, 0, 0, 0.10);
    --border-soft: #e2e5e9;
    --text-muted-2: #6c757d;

    /* هوية الشركة - مطابقة لألوان عرض السعر المطبوع لتناسق الهوية البصرية */
    --navy: #0B2545;
    --navy-light: #14345E;
    --gold: #C9A227;
    --gold-soft: #E8D9A0;
    --ink: #1B1F27;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: #F6F7F9;
}

/* ------------------------------------------------------------
   تنبيه ثابت أعلى الصفحة (Sticky) عند عدم كفاية النظام
------------------------------------------------------------ */
.insufficient-alert {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1080;
    background: linear-gradient(135deg, #C62828 0%, #E53935 100%);
    color: #fff;
    box-shadow: 0 4px 18px rgba(198, 40, 40, 0.35);
    animation: alertSlideDown 0.3s ease;
}
@keyframes alertSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}
.insufficient-alert-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 12px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.insufficient-alert-icon {
    font-size: clamp(1.2rem, 1.6vw, 1.5rem);
    margin-top: 2px;
    flex-shrink: 0;
}
.insufficient-alert-text {
    flex: 1;
    min-width: 0;
}
.insufficient-alert-text strong {
    display: block;
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    margin-bottom: 2px;
}
.insufficient-alert-text ul {
    margin: 4px 0 0;
    padding-inline-start: 18px;
    font-size: clamp(0.82rem, 1vw, 0.95rem);
    line-height: 1.6;
    opacity: 0.96;
}
.insufficient-alert-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}
.insufficient-alert-close:hover {
    background: rgba(255, 255, 255, 0.3);
}
body.has-insufficient-alert {
    padding-top: var(--insufficient-alert-height, 0px);
    transition: padding-top 0.25s ease;
}
@media (max-width: 576px) {
    .insufficient-alert-inner {
        padding: 10px 14px;
    }
}

/* ------------------------------------------------------------
   توصية عدد الألواح الفعلي المطلوب (الوضع اليدوي)
------------------------------------------------------------ */
.panel-recommendation {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: #FFF8E6;
    border: 1px solid #FFE4A3;
    color: #7A5C00;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-top: -6px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    line-height: 1.6;
}
.panel-recommendation i.fa-lightbulb {
    color: #C9A227;
    font-size: 1rem;
    flex-shrink: 0;
}
.panel-recommendation span {
    flex: 1;
    min-width: 200px;
}
.panel-recommendation strong {
    color: var(--navy);
    font-family: 'Cairo', sans-serif;
}
.panel-recommendation .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ------------------------------------------------------------
   ترويسة الهوية: اسم الشركة + موضوع الصفحة
------------------------------------------------------------ */
.brand-header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: #fff;
    padding: clamp(20px, 3vw, 34px) clamp(20px, 4vw, 40px);
    position: relative;
    overflow: hidden;
    text-align: center;
}
.brand-header::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold), transparent 75%);
}
.brand-header-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}
.brand-logo {
    width: clamp(44px, 4vw, 60px);
    height: clamp(44px, 4vw, 60px);
    object-fit: contain;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 6px;
    flex-shrink: 0;
}
.brand-text {
    text-align: start;
}
.brand-name {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: clamp(1.25rem, 2.4vw, 1.75rem);
    letter-spacing: 0.2px;
    line-height: 1.2;
}
.brand-tagline {
    font-size: clamp(0.78rem, 1vw, 0.95rem);
    color: var(--gold-soft);
    font-weight: 600;
}
.page-title-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: clamp(8px, 1vw, 12px) clamp(18px, 2vw, 26px);
    border-radius: 999px;
    font-weight: 700;
    font-size: clamp(0.92rem, 1.3vw, 1.15rem);
    color: #fff;
}
.page-title-chip i {
    color: var(--gold-soft);
}

/* ------------------------------------------------------------
   حاوية مرنة تكبر بسلاسة حتى الشاشات الضخمة (تلفزيونات/شاشات عرض)
   بدل ما تفضل واقفة عند max-width الافتراضي لـ Bootstrap
------------------------------------------------------------ */
@media (min-width: 1400px) {
    .container {
        max-width: 1140px;
    }
}
@media (min-width: 1800px) {
    .container {
        max-width: 1320px;
    }
}
@media (min-width: 2400px) {
    .container {
        max-width: 1600px;
    }
    body {
        font-size: 1.15rem;
    }
}
@media (min-width: 3200px) {
    .container {
        max-width: 2000px;
    }
    body {
        font-size: 1.35rem;
    }
}

/* ------------------------------------------------------------
   البطاقة الرئيسية
------------------------------------------------------------ */
.card {
    transition: box-shadow 0.2s ease;
    border-radius: var(--radius-xl) !important;
}

.card-header h3 {
    font-size: clamp(1.15rem, 2.2vw, 1.6rem);
    font-weight: 700;
    letter-spacing: 0.2px;
}

/* ------------------------------------------------------------
   تسميات وحقول الإدخال - وضوح أكبر
------------------------------------------------------------ */
.form-label {
    font-size: clamp(0.9rem, 1vw, 1.02rem);
    color: #2b2f33;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-soft);
    padding: clamp(10px, 1vw, 15px) clamp(14px, 1.2vw, 18px);
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    min-height: clamp(46px, 4vw, 58px);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 0.2rem rgba(11, 37, 69, 0.15);
}

/* أزرار الراديو (آلي / يدوي) كبطاقات صغيرة واضحة */
.form-check-inline {
    background: #f4f5f7;
    border: 1.5px solid var(--border-soft);
    border-radius: 999px;
    padding: 8px 16px;
    margin-inline-end: 0;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.form-check-inline:has(.form-check-input:checked) {
    border-color: #0d6efd;
    background: #eaf2ff;
}
.form-check-input {
    cursor: pointer;
}
.form-check-label {
    cursor: pointer;
    font-weight: 600;
}

/* ------------------------------------------------------------
   زر طباعة العرض العائم (ثابت أسفل يسار الصفحة)
------------------------------------------------------------ */
.floating-print-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1030;
    background: #0B2545;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 14px 22px;
    font-weight: 700;
    font-size: 0.98rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 22px rgba(11, 37, 69, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    animation: fadeIn 0.3s ease;
}
.floating-print-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(11, 37, 69, 0.45);
    background: #14345E;
}
.floating-print-btn i {
    font-size: 1.05rem;
}
@media (max-width: 576px) {
    .floating-print-btn {
        bottom: 16px;
        left: 16px;
        padding: 12px 18px;
        font-size: 0.9rem;
    }
    .floating-print-btn span {
        display: none; /* أيقونة فقط على الموبايل لتوفير المساحة */
    }
    .floating-print-btn {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        justify-content: center;
        padding: 0;
    }
}

/* ------------------------------------------------------------
   شاشة اختيار طريقة التصميم (الخطوة الأولى)
------------------------------------------------------------ */
#modeSelectScreen {
    animation: fadeIn 0.3s ease;
}

.mode-choice-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    background: #ffffff;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 3vw, 40px) clamp(18px, 2vw, 28px);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    height: 100%;
}
.mode-choice-card:hover {
    border-color: var(--navy);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}
.mode-choice-card:focus-visible {
    outline: 3px solid var(--navy);
    outline-offset: 2px;
}
.mode-choice-card.selected {
    border-color: var(--navy);
    background: #eef3fa;
}
.mode-choice-icon {
    font-size: clamp(2rem, 3vw, 3rem);
    margin-bottom: 6px;
}
.mode-choice-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: clamp(1.05rem, 1.4vw, 1.3rem);
    color: #1a1d20;
}
.mode-choice-desc {
    font-size: clamp(0.82rem, 1vw, 0.95rem);
    color: var(--text-muted-2);
    line-height: 1.5;
}

/* شريط الطريقة المختارة أعلى النموذج */
.chosen-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    background: #eef3fa;
    border: 1.5px solid #cddcee;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 0.95rem;
}

#formSection {
    animation: fadeIn 0.3s ease;
}

/* ------------------------------------------------------------
   كروت العروض المتعددة (الوضع الآلي)
------------------------------------------------------------ */
.offers-intro {
    text-align: center;
    margin-bottom: 18px;
}
.offers-intro h5 {
    font-weight: 700;
    margin-bottom: 4px;
}

.offers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.offer-card {
    background: #ffffff;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    position: relative;
}
.offer-card:hover {
    border-color: var(--navy);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.offer-badge-best,
.offer-badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 6px;
}
.offer-badge-best {
    background: #e8f5e9;
    color: #1e7e34;
}
.offer-badge {
    background: #eef1f4;
    color: #4a4f54;
}

.offer-price {
    font-family: 'Cairo', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 4px;
}
.offer-price span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted-2);
}

.offer-line {
    font-size: 0.9rem;
    color: #2b2f33;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ------------------------------------------------------------
   القسم اليدوي
------------------------------------------------------------ */
#manualSection {
    background: #f8f9fa;
    border-radius: var(--radius-lg);
    padding: 20px 25px;
    border: 2px solid var(--border-soft);
    animation: fadeIn 0.3s ease;
}
#autoSection {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.inverter-item {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}
.inverter-item .inverter-select {
    flex: 1;
    height: 46px;
    border-radius: var(--radius-sm);
}
.inverter-item .btn-remove-inverter {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#addInverterBtn {
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-weight: 600;
}

/* ------------------------------------------------------------
   الأزرار الرئيسية - مظهر عصري موحّد
------------------------------------------------------------ */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: 0.2px;
}
.btn-lg {
    padding: clamp(14px, 1.4vw, 20px) clamp(20px, 2.5vw, 30px);
    font-size: clamp(1.02rem, 1.2vw, 1.2rem);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}
.btn-lg:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-1px);
}
.btn-lg:active {
    transform: translateY(0);
}

/* توحيد لون Bootstrap الأساسي مع هوية الشركة (كحلي بدل الأزرق الافتراضي) */
.btn-primary {
    background-color: var(--navy);
    border-color: var(--navy);
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--navy-light);
    border-color: var(--navy-light);
}
.text-primary {
    color: var(--navy) !important;
}
.bg-primary {
    background-color: var(--navy) !important;
}

/* ============================================================
   منطقة النتائج
   ============================================================ */
.result-card {
    background: #ffffff;
    border: 1.5px solid var(--border-soft);
    border-radius: var(--radius-xl);
    padding: clamp(16px, 3vw, 32px);
    box-shadow: var(--shadow-medium);
}

.result-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    padding-bottom: 12px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--border-soft);
    color: var(--navy);
}

/* شبكة ملخص علوية (بطاقات صغيرة بدل أسطر متلاصقة) */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.summary-box {
    background: #f8f9fb;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}
.summary-box .summary-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted-2);
    margin-bottom: 4px;
}
.summary-box .summary-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1d20;
}

/* عناوين فرعية لأقسام النتائج */
.result-section-title {
    font-weight: 700;
    font-size: 1.02rem;
    margin: 22px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2b2f33;
}

/* ------------------------------------------------------------
   جداول النتائج (إنفيرترات / بطارية / ألواح)
------------------------------------------------------------ */
.result-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 480px;
}
.result-table thead th {
    background: #f1f3f5;
    color: #444;
    font-weight: 700;
    text-align: start;
    padding: 10px 14px;
    white-space: nowrap;
    border-bottom: 1.5px solid var(--border-soft);
}
.result-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #eef0f2;
    vertical-align: middle;
}
.result-table tbody tr:last-child td {
    border-bottom: none;
}
.result-table tbody tr:hover {
    background: #fafbfc;
}
.result-table tfoot td {
    padding: 10px 14px;
    font-weight: 700;
    background: #f8f9fb;
}

/* صورة المنتج داخل الجدول - حجم معقول وموحّد */
.product-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}
.product-cell .product-name {
    font-weight: 600;
    color: #1a1d20;
}
.product-cell .product-sub {
    font-size: 0.8rem;
    color: var(--text-muted-2);
}

/* شارة السعر */
.price-tag {
    background: #e8f5e9;
    color: #1e7e34;
    padding: 3px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85em;
    white-space: nowrap;
}

/* حالة كفاية النظام */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
}
.status-sufficient {
    background: #e8f5e9;
    color: #1e7e34;
}
.status-insufficient {
    background: #fdeaea;
    color: #c62828;
}

/* صندوق تحذيرات */
.warning-box {
    background: #fff8e6;
    border: 1.5px solid #ffe4a3;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: #7a5c00;
    font-size: 0.92rem;
    line-height: 1.7;
}

/* صندوق التكلفة الإجمالية */
.total-cost-box {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    font-weight: 700;
    border-radius: var(--radius-md);
    padding: 16px 22px;
    font-size: clamp(1.05rem, 2vw, 1.3rem);
    color: #1e7e34;
    border: 2px solid #81c784;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* بدائل النظام (الوضع الآلي) */
.alternative-item {
    background: #f8f9fb;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 8px;
    font-size: 0.92rem;
}

/* مؤشر التحميل */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px 10px;
    color: var(--text-muted-2);
    font-weight: 600;
}

/* ============================================================
   تجاوب للموبايل والشاشات الصغيرة جداً
   ============================================================ */
@media (max-width: 576px) {
    .inverter-item {
        flex-wrap: wrap;
    }
    .inverter-item .inverter-select {
        flex: 1 1 100%;
    }
    .inverter-item .btn-remove-inverter {
        flex: 0 0 auto;
    }
    #manualSection {
        padding: 14px 14px;
    }
    .result-table {
        font-size: 0.85rem;
        min-width: 420px;
    }
    .product-thumb {
        width: 38px;
        height: 38px;
    }
    .summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    .total-cost-box {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* آيفون وشاشات ضيقة جداً: الجدول يتقلص ليأخذ عرض الشاشة كاملاً بدل التحريك يمين/يسار */
@media (max-width: 430px) {
    .result-table-wrap {
        overflow-x: visible;
    }
    .result-table {
        min-width: 0;
        width: 100%;
        font-size: 0.72rem;
        table-layout: fixed;
    }
    .result-table thead th,
    .result-table tbody td,
    .result-table tfoot td {
        padding: 6px 5px;
        white-space: normal;
        word-break: break-word;
    }
    .product-cell {
        gap: 5px;
    }
    .product-thumb {
        width: 26px;
        height: 26px;
    }
    .product-cell .product-name {
        font-size: 0.72rem;
        line-height: 1.2;
    }
    .product-cell .product-sub {
        font-size: 0.65rem;
    }
    .price-tag {
        padding: 2px 6px;
        font-size: 0.68rem;
    }
}

/* شاشات لوحية متوسطة */
@media (min-width: 768px) and (max-width: 1199px) {
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* دعم تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}