@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
    --brand-blue: #0c4684;
    --brand-blue-dark: #08325e;
    --brand-rust: #8c3405;
    --brand-beige: #f7f4ef;
    --brand-beige-border: #e7e0d5;
    --ink-dark: #1f2937;
    --ink-muted: #374151;
    --border-soft: #e5e7eb;
}

/* =========================================================
   0. الإعدادات العامة المشتركة (كل الصفحات)
   ========================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
}

body {
    font-family: 'Cairo', sans-serif;
    color: var(--ink-dark);
    background-color: #eceff3;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.65;
}

a {
    color: inherit;
    text-decoration: none;
}

/* =========================================================
   1. خاص بصفحة الهيرو الرئيسية (index.php)
   ========================================================= */
.home-only-body {
    overflow-x: hidden;
}

.home-only-body .hero-stage {
    position: relative;
    flex: 1 0 auto;
    height: calc(100vh - 42px);
    min-height: 540px;
    width: 100%;
    background-image: url('../images/hero-bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.home-only-body .hero-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.34) 0%,
        rgba(255, 255, 255, 0.14) 55%,
        rgba(15, 23, 42, 0.24) 100%
    );
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hero-logo-box {
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 16px;
}

.hero-logo-box img {
    display: block;
    max-height: 92px;
    width: auto;
    object-fit: contain;
    background: transparent;
    filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.9));
}

.hero-title {
    font-size: clamp(1.9rem, 3.8vw, 2.95rem);
    font-weight: 800;
    color: #18202a;
    text-shadow: 0 2px 14px rgba(255, 255, 255, 0.95);
    line-height: 1.3;
    margin-bottom: 6px;
}

.hero-subtitle {
    font-size: clamp(1.25rem, 2.4vw, 1.85rem);
    font-weight: 700;
    color: #1f2937;
    text-shadow: 0 2px 12px rgba(255, 255, 255, 0.95);
    line-height: 1.34;
    margin-bottom: 8px;
}

.hero-lead {
    max-width: 820px;
    font-size: clamp(0.96rem, 1.4vw, 1.1rem);
    font-weight: 600;
    color: #1f2937;
    background: transparent;
    padding: 0;
    border-radius: 0;
    text-shadow: 0 1px 10px rgba(255, 255, 255, 0.95);
    margin-bottom: 24px;
}

/* شريط الفلترة البيضاوي الموحد في index.php و reports.php */
.filter-capsule-form {
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 999px;
    padding: 10px 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-select-wrap {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
}

.filter-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 46px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    color: #1f2937;
    font-family: 'Cairo', sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    padding: 0 14px 0 32px;
    cursor: pointer;
    outline: none;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.filter-select-wrap:first-of-type .filter-select {
    border-top-right-radius: 24px;
    border-bottom-right-radius: 24px;
}

.filter-select:hover,
.filter-select:focus {
    background: #ffffff;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(12, 70, 132, 0.12);
}

.filter-chevron {
    position: absolute;
    left: 12px;
    top: 46%;
    transform: translateY(-50%);
    color: var(--brand-rust);
    font-size: 1rem;
    font-weight: 700;
    pointer-events: none;
    line-height: 1;
}

.filter-submit-btn {
    flex: 0 0 auto;
    height: 46px;
    padding: 0 24px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #135296 0%, var(--brand-blue-dark) 100%);
    color: #ffffff;
    font-family: 'Cairo', sans-serif;
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 14px rgba(12, 70, 132, 0.28);
    transition: filter 0.15s ease, transform 0.15s ease;
}

.filter-submit-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.filter-funnel-icon {
    font-size: 0.85rem;
    line-height: 1;
}

/* =========================================================
   2. خاص بصفحة نتائج الفلترة (reports.php) والهيدر الداخلي
   ========================================================= */
.reports-page-body {
    background-color: var(--brand-beige);
}

.reports-top-header {
    background: #ffffff;
    border-bottom: 1px solid var(--brand-beige-border);
    padding: 10px 28px;
    box-shadow: 0 2px 10px rgba(140, 52, 5, 0.04);
    flex-shrink: 0;
}

.reports-top-inner {
    max-width: 1360px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reports-brand-logo {
    background: transparent;
    display: inline-flex;
    align-items: center;
}

.reports-brand-logo img {
    display: block;
    max-height: 50px;
    width: auto;
    object-fit: contain;
    background: transparent;
}

.back-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--brand-beige-border);
    color: var(--brand-blue-dark);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 7px 15px;
    border-radius: 10px;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.back-home-btn:hover {
    background: var(--brand-beige);
    border-color: var(--brand-rust);
    color: var(--brand-rust);
}

.reports-main-wrap {
    max-width: 1360px;
    width: 100%;
    margin: 24px auto 44px;
    padding: 0 24px;
}

.reports-filter-box {
    margin-bottom: 22px;
}

/* أيقونات SVG والقوائم المنسدلة المخصصة في reports.php */
.filter-prefix-svg {
    width: 15px;
    height: 15px;
    color: var(--brand-rust);
    flex-shrink: 0;
    pointer-events: none;
}

.filter-chevron-svg {
    width: 14px;
    height: 14px;
    color: var(--brand-rust);
    flex-shrink: 0;
    pointer-events: none;
}

.filter-btn-svg,
.view-btn-svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.custom-dd-wrap {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
}

.custom-dd-native-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.custom-dd-trigger {
    width: 100%;
    height: 46px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 0 11px;
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ink-dark);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.custom-dd-wrap:first-of-type .custom-dd-trigger {
    border-top-right-radius: 24px;
    border-bottom-right-radius: 24px;
}

.custom-dd-trigger:hover,
.custom-dd-wrap.is-open .custom-dd-trigger {
    background: #ffffff;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(12, 70, 132, 0.12);
}

.custom-dd-label {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-dd-menu {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    left: 0;
    background: #ffffff;
    border: 1px solid var(--brand-beige-border);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 14px 30px rgba(8, 50, 94, 0.14);
    z-index: 60;
    display: none;
    max-height: 240px;
    overflow-y: auto;
}

.custom-dd-wrap.is-open .custom-dd-menu {
    display: block;
}

.custom-dd-option {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 9px;
    padding: 8px 12px;
    text-align: right;
    font-family: 'Cairo', sans-serif;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--ink-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.custom-dd-option:hover {
    background: var(--brand-beige);
    color: var(--brand-rust);
}

.custom-dd-option.is-selected {
    background: linear-gradient(180deg, #135296 0%, var(--brand-blue-dark) 100%);
    color: #ffffff;
}

.reports-table-card {
    background: #ffffff;
    border: 1px solid var(--brand-beige-border);
    border-radius: 18px;
    padding: 24px 28px 26px;
    box-shadow: 0 8px 24px rgba(140, 52, 5, 0.05);
}

.reports-card-header {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f2ede6;
}

.reports-card-header h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand-blue-dark);
}

.reports-table-scroll {
    width: 100%;
    overflow-x: auto;
}

.reports-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.reports-data-table thead th {
    background: var(--brand-beige);
    color: var(--brand-rust);
    font-size: 0.88rem;
    font-weight: 800;
    text-align: right;
    padding: 13px 14px;
    border-top: 1px solid var(--brand-beige-border);
    border-bottom: 1px solid var(--brand-beige-border);
    white-space: nowrap;
}

.reports-data-table tbody td {
    padding: 14px 14px;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3efe9;
    color: #2c3542;
    vertical-align: middle;
}

.reports-data-table tbody tr:hover {
    background: #fcfaf7;
}

.report-code-cell {
    font-weight: 800;
    color: var(--brand-blue);
    white-space: nowrap;
}

.report-title-cell {
    font-weight: 700;
    color: #111827;
}

.tag-pill {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.tag-rust {
    background: #f9ece5;
    color: var(--brand-rust);
    border: 1px solid #edd6c9;
}

.tag-slate {
    background: #eef3f8;
    color: var(--brand-blue-dark);
    border: 1px solid #d7e2ee;
}

.report-date-cell {
    white-space: nowrap;
    color: #4b5563;
    font-weight: 600;
}

.view-action-btn {
    background: linear-gradient(180deg, #135296 0%, var(--brand-blue-dark) 100%);
    border: 1px solid var(--brand-blue-dark);
    color: #ffffff;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(12, 70, 132, 0.2);
    transition: filter 0.15s ease, transform 0.15s ease;
}

.view-action-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.eye-icon {
    font-size: 0.82rem;
    color: #ffffff;
}

.pagination-bar {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-nav-btn,
.page-num-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--brand-beige-border);
    background: #ffffff;
    color: var(--ink-dark);
    font-size: 0.86rem;
    font-weight: 700;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.page-num-btn:hover,
.page-nav-btn:hover {
    background: var(--brand-beige);
    border-color: var(--brand-blue);
}

.page-num-btn.is-active {
    background: var(--brand-blue-dark);
    border-color: var(--brand-blue-dark);
    color: #ffffff;
}

.page-nav-btn.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.page-dots {
    color: var(--brand-rust);
    font-weight: 700;
    padding: 0 4px;
}

.empty-state-box {
    background: var(--brand-beige);
    border: 1px dashed var(--brand-beige-border);
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    color: var(--ink-muted);
    font-weight: 700;
}

/* =========================================================
   3. خاص بصفحة عرض التقرير الفردي (view_report.php)
   ========================================================= */
.report-view-body {
    background-color: var(--brand-beige);
    height: 100vh;
    overflow: hidden;
}

.report-view-main {
    max-width: 1360px;
    width: 100%;
    margin: 14px auto;
    padding: 0 24px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.report-detail-layout {
    display: grid;
    grid-template-columns: minmax(290px, 0.72fr) minmax(0, 1.95fr);
    gap: 22px;
    align-items: stretch;
    height: 100%;
    min-height: 0;
}

.report-info-column {
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.report-viewer-column {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.viewer-shell-card {
    background: #d8dce2;
    border: 1px solid #cbd2dc;
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.viewer-toolbar {
    background: #333840;
    color: #f3f4f6;
    border-radius: 12px 12px 6px 6px;
    padding: 7px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.viewer-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.viewer-tool-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 6px;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.viewer-tool-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.viewer-zoom-label,
.viewer-doc-badge {
    font-size: 0.82rem;
    font-weight: 700;
    color: #e5e7eb;
    padding: 0 6px;
}

.viewer-canvas-wrap {
    background: #525659;
    border-radius: 6px 6px 12px 12px;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.viewer-zoom-target {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pdf-preview-frame {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    border: none;
    border-radius: 6px;
    background: #ffffff;
    display: block;
}

.report-sheet-preview {
    background: #ffffff;
    border-radius: 6px;
    padding: 24px 28px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    color: #1f2937;
}

.sheet-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--brand-beige);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--brand-rust);
}

.sheet-main-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--brand-blue-dark);
    margin-bottom: 6px;
}

.sheet-project-line {
    font-size: 0.94rem;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 18px;
}

.sheet-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    background: var(--brand-beige);
    border: 1px solid var(--brand-beige-border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 18px;
    font-size: 0.88rem;
}

.sheet-body-block h4 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--brand-rust);
    margin-bottom: 8px;
}

.sheet-body-block p {
    font-size: 0.92rem;
    line-height: 1.75;
    color: #374151;
}

.report-info-card {
    background: #ffffff;
    border: 1px solid var(--brand-beige-border);
    border-radius: 18px;
    padding: 22px 24px;
    box-shadow: 0 8px 24px rgba(140, 52, 5, 0.05);
    display: flex;
    flex-direction: column;
}

.info-card-heading {
    font-size: 1.26rem;
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 4px;
}

.info-report-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #374151;
    line-height: 1.45;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid #f0ece4;
}

.info-rows-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-bottom: 0;
}

.info-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
}

.info-row-item dt {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #4b5563;
    font-weight: 700;
    white-space: nowrap;
}

.info-svg-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.icon-rust {
    color: var(--brand-rust);
}

.icon-blue {
    color: var(--brand-blue);
}

.icon-green {
    color: #15803d;
}

.info-row-item dd {
    font-weight: 700;
    color: #1f2937;
    text-align: left;
}

.info-type-pill {
    display: inline-block;
    background: #f8ece6;
    color: var(--brand-rust);
    border: 1px solid #ebd3c6;
    border-radius: 7px;
    padding: 2px 10px;
    font-size: 0.82rem;
    font-weight: 700;
}

.info-ref-code {
    font-weight: 800 !important;
    color: var(--brand-blue-dark) !important;
}

.status-approved-badge {
    display: inline-block;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    padding: 2px 10px;
    font-size: 0.82rem;
    font-weight: 700;
}

.info-actions-stack {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-share-report {
    width: 100%;
    height: 42px;
    border: 1px solid #d5b2a1;
    border-radius: 10px;
    background: linear-gradient(180deg, #faf0ea 0%, #f1dfd5 100%);
    color: var(--brand-rust);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(140, 52, 5, 0.08);
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn-share-report:hover {
    background: linear-gradient(180deg, #f5e5dc 0%, #ead2c5 100%);
    transform: translateY(-1px);
}

.btn-svg-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.share-feedback-msg {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--brand-blue-dark);
    text-align: center;
    min-height: 18px;
}

/* =========================================================
   4. خاص بالفوتر الموحد (includes/footer.php)
   ========================================================= */
.client-footer {
    margin-top: auto;
    background-color: #eceff3;
    border-top: 1px solid #dfe3e8;
    padding: 9px 20px;
    text-align: center;
    flex-shrink: 0;
}

.footer-single-line {
    font-size: 0.84rem;
    font-weight: 700;
    color: #374151;
    margin: 0 auto;
}

/* =========================================================
   5. الاستجابة للموبايل والتابلت (index.php, reports.php, view_report.php) والطباعة
   ========================================================= */
@media (max-width: 1024px) {
    .report-view-body {
        height: auto;
        overflow: auto;
    }

    .report-view-main {
        margin: 18px auto 32px;
    }

    .report-detail-layout {
        grid-template-columns: 1fr;
        height: auto;
        align-items: start;
    }

    .viewer-canvas-wrap {
        flex: none;
        height: 540px;
    }

    .pdf-preview-frame {
        height: 100%;
    }
}

@media (max-width: 960px) {
    .home-only-body .hero-stage {
        height: auto;
        min-height: calc(100vh - 42px);
        overflow: visible;
    }

    .filter-capsule-form {
        border-radius: 20px;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }

    .custom-dd-trigger,
    .custom-dd-wrap:first-of-type .custom-dd-trigger {
        height: 44px;
        border-radius: 12px;
    }

    .filter-select {
        height: 44px;
        border-radius: 12px;
    }

    .filter-select-wrap:first-of-type .filter-select {
        border-top-right-radius: 12px;
        border-bottom-right-radius: 12px;
    }

    .filter-submit-btn {
        width: 100%;
        justify-content: center;
        border-radius: 14px;
    }

    .reports-main-wrap,
    .report-view-main {
        padding: 0 14px;
    }

    .reports-table-card {
        padding: 16px;
    }
}

@media print {
    .site-header,
    .client-footer,
    .viewer-toolbar,
    .info-actions-stack {
        display: none !important;
    }

    body,
    .report-view-body,
    .report-view-main,
    .viewer-shell-card,
    .viewer-canvas-wrap,
    .report-info-card {
        background: #ffffff !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .report-detail-layout {
        display: block;
    }
}