@font-face{
  font-family:SakkalFallback;
  src:local('Sakkal Majalla'),local('Sakkal Majalla Regular');
}

*{
  box-sizing:border-box;
}

.daily-body{
  margin:0;
  background:#f5f8fb;
  color:#17334a;
  font-family:SakkalFallback,'Noto Naskh Arabic','Cairo',sans-serif;
}

.daily-app{
  padding:22px;
  max-width:1900px;
  margin:auto;
}

.daily-head{
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:center;
  margin-bottom:16px;
}

.daily-head h1{
  margin:2px 0;
  font-size:32px;
}

.daily-head p{
  margin:0;
  color:#64778a;
}

.daily-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.template-box{
  background:#fff;
  border:1px solid #e2eaf0;
  border-radius:18px;
  padding:14px 18px;
  margin-bottom:16px;
  display:flex;
  align-items:center;
  gap:18px;
  box-shadow:0 8px 30px #18384b0a;
}

.template-tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.template-tabs button{
  border:1px solid #cad9df;
  background:#fff;
  padding:10px 18px;
  border-radius:12px;
  font:inherit;
  font-weight:700;
  color:#31556a;
  cursor:pointer;
}

.template-tabs button.active{
  background:#00533d;
  color:#fff;
  border-color:#00533d;
}

.daily-workspace{
  display:grid;
  grid-template-columns:minmax(540px,1fr) minmax(500px,.9fr);
  gap:24px;
  align-items:start;
}

.daily-editor,
.daily-preview-wrap{
  min-width:0;
}

.daily-editor{
  padding:18px;
}

.title-field{
  display:grid;
  gap:6px;
  margin-bottom:14px;
}

.title-field input,
.field-card input,
.field-card select{
  width:100%;
  border:0;
  background:transparent;
  font:inherit;
  font-size:18px;
  outline:0;
  color:#16384b;
}

.top-cards{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:12px;
}

.field-card{
  min-height:100px;
  border:1px solid #dce8ed;
  border-radius:16px;
  background:linear-gradient(180deg,#fff,#f9fcfd);
  padding:13px 15px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:5px;
  text-align:right;
  box-shadow:0 7px 20px #173b4e0a;
}

.field-card span{
  font-size:14px;
  color:#60798a;
}

.date-card{
  cursor:pointer;
  font:inherit;
}

.date-card strong{
  color:#00533d;
  font-size:20px;
}

.date-card small{
  color:#3e6f8e;
  font-size:15px;
}

.evidence-note{
  margin:15px 0;
  padding:11px 14px;
  border-radius:12px;
  background:#fff8e8;
  border:1px solid #f0d9a3;
  color:#76551a;
}

.evidence-note small{
  display:block;
}

.entry-row{
  display:grid;
  grid-template-columns:42px minmax(180px,2fr) 120px minmax(230px,1.4fr);
  gap:8px;
  padding:9px 0;
  border-bottom:1px solid #edf1f3;
  align-items:start;
}

.entry-row.head{
  background:#00533d;
  color:#fff;
  border-radius:12px;
  padding:9px;
  font-weight:700;
  text-align:center;
}

.entry-row input,
.entry-row textarea,
.entry-row select{
  width:100%;
  border:1px solid #d8e2e8;
  border-radius:10px;
  padding:9px;
  font:inherit;
  background:#fff;
}

.entry-row textarea{
  min-height:58px;
  resize:vertical;
}

.evidence-controls{
  display:flex;
  gap:5px;
  flex-wrap:wrap;
}

.evidence-controls button{
  border:1px solid #cfe0e5;
  background:#fff;
  border-radius:8px;
  padding:6px 8px;
  font:inherit;
  cursor:pointer;
}

.evidence-controls button.on{
  background:#e8f4f0;
  border-color:#00533d;
  color:#00533d;
}

.evidence-preview{
  margin-top:7px;
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.thumb{
  width:82px;
  height:64px;
  border-radius:8px;
  overflow:hidden;
  border:1px solid #d9e4e8;
  position:relative;
}

.thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.thumb button{
  position:absolute;
  bottom:2px;
  right:2px;
  font-size:11px;
  border:0;
  border-radius:6px;
  background:#fff;
  padding:2px 4px;
}

.preview-label{
  font-weight:800;
  margin-bottom:8px;
}

.daily-preview-wrap{
  position:sticky;
  top:12px;
  background:#eaf0f3;
  border-radius:18px;
  padding:16px;
  overflow:auto;
  max-height:calc(100vh - 24px);
}

.daily-preview{
  width:210mm;
  min-height:297mm;
  margin:auto;
  transform-origin:top center;
}

.daily-preview .report-print-page{
  margin:0!important;
  box-shadow:0 10px 35px #102f4020;
}

.daily-info{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:8px;
  margin:7mm 0 5mm;
}

.daily-info>div{
  border:1px solid #d9e4e8;
  border-radius:8px;
  padding:8px;
  text-align:center;
  background:#fff;
}

.daily-info b{
  display:block;
  color:#00533d;
}

.daily-info .greg{
  display:block;
  color:#3e6f8e;
  font-size:11px;
  margin-top:2px;
}

/* ===== التقرير النهائي / المعاينة ===== */

.daily-table{
  width:calc(100% - 4px);
  max-width:calc(100% - 4px);
  margin:0 2px;
  border-collapse:separate;
  border-spacing:0;
  table-layout:fixed;
  box-sizing:border-box;
  border:1px solid #8fa6a1;
  background:#fff;
}

.daily-table th,
.daily-table td{
  border:0;
  border-bottom:1px solid #9fb2b9;
  border-inline-start:1px solid #9fb2b9;
  box-sizing:border-box;
  vertical-align:middle;
  text-align:center;
}

.daily-table th{
  background:#00533d;
  color:#fff;
  padding:7px 5px;
}

.daily-table td{
  padding:6px 5px;
}

.daily-table tr:last-child td{
  border-bottom:0;
}

.daily-table tr > :first-child{
  border-inline-start:0;
}

/* م 5% - البرنامج 36% - وقت التنفيذ 14% - الشواهد 45% */
.daily-table th:nth-child(1),
.daily-table td:nth-child(1){width:5%}
.daily-table th:nth-child(2),
.daily-table td:nth-child(2){width:36%}
.daily-table th:nth-child(3),
.daily-table td:nth-child(3){width:14%}
.daily-table th:nth-child(4),
.daily-table td:nth-child(4){
  width:45%;
  /* خط مادي ثابت لجهة الشواهد حتى لا يختفي في المعاينة أو الطباعة */
  border-left:1.5px solid #8fa6a1!important;
  box-shadow:inset 1px 0 0 #8fa6a1;
}

.daily-program{
  text-align:right!important;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

/* صور الشواهد
   تصميم مربع أنيق: صورتان متساويتان بجانب بعض، مع مسافة خفيفة،
   وقص داخلي مرن يحافظ على جودة الصورة ولا يسمح بأي تداخل. */
.daily-evidence-images{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  justify-content:center;
  align-items:center;
  justify-items:center;
  gap:2.2mm;
  width:100%;
  padding:2.2mm 2.5mm;
  box-sizing:border-box;
}

.daily-evidence-image-frame{
  display:block;
  width:100%;
  max-width:31mm;
  aspect-ratio:1 / 1;
  height:auto;
  overflow:hidden;
  border:1px solid #9eb7af;
  border-radius:3mm;
  background:#fff;
  box-shadow:0 1.5px 4px #17384b17;
  position:relative;
  break-inside:avoid;
}

.daily-evidence-image-frame img{
  display:block;
  width:100%;
  height:100%;
  max-width:none;
  max-height:none;
  object-fit:cover;
  object-position:center;
  transform-origin:center center;
  image-rendering:auto;
  backface-visibility:hidden;
}

/* إذا كان الشاهد صورة واحدة: تبقى مربعة ومتمركزة بنفس فخامة الصورتين */
.daily-evidence-images.single{
  grid-template-columns:1fr;
}

.daily-evidence-images.single .daily-evidence-image-frame{
  width:31mm;
  max-width:82%;
  aspect-ratio:1 / 1;
  height:auto;
  margin:0 auto;
}

/* رابط الشاهد: أيقونة متجهة واضحة بدل الرابط الطويل داخل التقرير */
.daily-link{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:22mm;
}

.daily-evidence-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:17mm;
  height:17mm;
  border:1.2px solid #0b6b55;
  border-radius:3mm;
  background:#fff;
  color:#00533d!important;
  text-decoration:none!important;
  box-shadow:0 1.5px 4px #17384b12;
  transition:transform .15s ease,box-shadow .15s ease,background .15s ease;
}

.daily-evidence-link:hover{
  transform:translateY(-1px);
  background:#f3faf7;
  box-shadow:0 4px 10px #17384b18;
}

.daily-evidence-link svg{
  width:9mm;
  height:9mm;
  display:block;
  stroke:currentColor;
}

/* شاهد PDF: أيقونة فقط بدون اسم الملف */
.daily-pdf{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:24mm;
}

.daily-pdf-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18mm;
  height:22mm;
  text-decoration:none!important;
  cursor:pointer;
  border-radius:7px;
  transition:transform .15s ease,box-shadow .15s ease;
}

.daily-pdf-icon:hover{
  transform:translateY(-1px);
  box-shadow:0 5px 14px #17384b1c;
}

.daily-pdf-icon.is-loading{
  opacity:.55;
  cursor:wait;
}

.daily-pdf-sheet{
  position:relative;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  width:13mm;
  height:17mm;
  padding-bottom:2.2mm;
  background:linear-gradient(180deg,#ef4b43,#df2f29);
  border:1px solid #d52d28;
  border-radius:2.2mm;
  box-shadow:0 2px 7px #9a24241f;
  color:#fff;
  font-family:Arial,sans-serif;
  overflow:hidden;
}

.daily-pdf-sheet::before{
  content:"";
  position:absolute;
  top:0;
  right:0;
  width:5mm;
  height:5mm;
  background:linear-gradient(225deg,#ffd9d6 49%,#c92521 50%,#c92521 53%,transparent 54%);
}

.daily-pdf-sheet b{
  position:relative;
  z-index:1;
  font-size:10px;
  line-height:1;
  letter-spacing:.2px;
  color:#fff;
}

.daily-approvals{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:8px;
  margin-top:8mm;
  text-align:center;
}

.daily-approvals img{
  max-width:32mm;
  max-height:18mm;
  object-fit:contain;
}

.repository{
  margin-top:18px;
}

.repo-item{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:12px;
  border-bottom:1px solid #e5ecef;
}

.hidden{
  display:none!important;
}

.daily-modal{
  position:fixed;
  inset:0;
  background:#102e3d99;
  display:grid;
  place-items:center;
  z-index:9999;
  padding:18px;
}

.date-dialog,
.crop-dialog{
  width:min(520px,95vw);
  background:#fff;
  border-radius:20px;
  padding:18px;
  box-shadow:0 30px 80px #0003;
}

.date-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.date-top button{
  border:0;
  background:#eef5f3;
  border-radius:10px;
  padding:8px 14px;
  font-size:24px;
}

.week,
.days-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:5px;
  text-align:center;
}

.week{
  margin:12px 0 6px;
  color:#6d7f8b;
  font-size:13px;
}

.days-grid button{
  border:1px solid #e0e8ec;
  background:#fff;
  border-radius:9px;
  padding:9px 2px;
  font:inherit;
}

.days-grid button.selected{
  background:#00533d;
  color:#fff;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:14px;
}

.crop-stage{
  height:300px;
  background:#eef3f5;
  overflow:hidden;
  position:relative;
  border-radius:14px;
  margin:12px 0;
}

.crop-stage img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.crop-frame{
  position:absolute;
  inset:15%;
  border:3px solid #fff;
  box-shadow:0 0 0 999px #0006;
  pointer-events:none;
}

.crop-dialog label{
  display:grid;
  grid-template-columns:90px 1fr;
  gap:8px;
  margin:8px 0;
}

@media(max-width:1150px){
  .daily-workspace{
    grid-template-columns:1fr;
  }

  .daily-preview-wrap{
    position:static;
    max-height:none;
  }

  .daily-preview{
    transform:scale(.8);
    margin-bottom:-60mm;
  }
}

@media(max-width:720px){
  .daily-app{
    padding:10px;
  }

  .daily-head{
    align-items:flex-start;
    flex-direction:column;
  }

  .top-cards{
    grid-template-columns:1fr;
  }

  .entry-row{
    grid-template-columns:34px 1fr;
  }

  .entry-row>*:nth-child(3),
  .entry-row>*:nth-child(4){
    grid-column:2;
  }

  .entry-row.head{
    display:none;
  }

  .daily-preview{
    transform:scale(.48);
    margin-right:-54mm;
    margin-bottom:-150mm;
  }

  .template-box{
    align-items:flex-start;
    flex-direction:column;
  }
}

@media print{
  @page{
    size:A4 portrait;
    margin:0;
  }

  html,
  body{
    width:210mm!important;
    min-width:210mm!important;
    margin:0!important;
    padding:0!important;
    background:#fff!important;
    overflow:visible!important;
  }

  body.daily-body{
    display:block!important;
  }

  .daily-app{
    display:block!important;
    width:210mm!important;
    margin:0!important;
    padding:0!important;
  }

  .daily-head,
  .template-box,
  .daily-editor,
  .preview-label,
  .repository,
  .daily-modal,
  .toast{
    display:none!important;
  }

  .daily-workspace{
    display:block!important;
    margin:0!important;
    padding:0!important;
  }

  .daily-preview-wrap{
    display:block!important;
    position:static!important;
    width:210mm!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    background:none!important;
    overflow:visible!important;
    border-radius:0!important;
  }

  .daily-preview{
    display:block!important;
    transform:none!important;
    width:210mm!important;
    min-height:297mm!important;
    height:auto!important;
    margin:0!important;
    padding:0!important;
  }

  .daily-preview .report-print-page{
    display:block!important;
    width:210mm!important;
    min-height:297mm!important;
    height:auto!important;
    margin:0!important;
    box-shadow:none!important;
    overflow:visible!important;
    page-break-after:auto!important;
    break-after:auto!important;
  }

  .daily-table{
    width:calc(100% - 4mm)!important;
    max-width:calc(100% - 4mm)!important;
    margin-left:2mm!important;
    margin-right:2mm!important;
    border:1px solid #8fa6a1!important;
  }

  .daily-table th:nth-child(4),
  .daily-table td:nth-child(4){
    border-left:1.5px solid #8fa6a1!important;
    box-shadow:inset 1px 0 0 #8fa6a1!important;
  }

  .daily-evidence-images{
    gap:2mm!important;
    padding:2mm 2.3mm!important;
  }

  .daily-evidence-image-frame{
    width:100%!important;
    max-width:30mm!important;
    aspect-ratio:1 / 1!important;
    height:auto!important;
    border-radius:2.5mm!important;
    box-shadow:none!important;
  }

  .daily-evidence-images.single .daily-evidence-image-frame{
    width:30mm!important;
    max-width:82%!important;
    aspect-ratio:1 / 1!important;
    height:auto!important;
  }

  .daily-evidence-link{
    box-shadow:none!important;
  }

  .daily-pdf-icon{
    box-shadow:none!important;
  }
}

/* ==========================================================
   2026-08-29 — إصلاح نهائي: منع خروج عمود الشواهد عن صفحة A4
   ========================================================== */

/* نترك هامش أمان فعلي داخل محتوى الصفحة؛ لا يلامس الجدول حافة القالب. */
.daily-preview .report-page-content{
  overflow:hidden!important;
}

.daily-table{
  width:calc(100% - 6mm)!important;
  max-width:calc(100% - 6mm)!important;
  margin-inline:3mm!important;
  table-layout:fixed!important;
  border-collapse:separate!important;
  border-spacing:0!important;
  border:1.2px solid #8fa6a1!important;
  box-shadow:inset 0 0 0 .25px #8fa6a1;
  overflow:hidden!important;
}

/* توزيع متوازن مع مساحة ممتازة للشواهد، بدون تجاوز عرض الصفحة. */
.daily-table th:nth-child(1),
.daily-table td:nth-child(1){width:5%!important}
.daily-table th:nth-child(2),
.daily-table td:nth-child(2){width:37%!important}
.daily-table th:nth-child(3),
.daily-table td:nth-child(3){width:15%!important}
.daily-table th:nth-child(4),
.daily-table td:nth-child(4){
  width:43%!important;
  border-left:1.2px solid #8fa6a1!important;
  box-shadow:inset 1px 0 0 #8fa6a1!important;
  overflow:hidden!important;
  padding-left:2mm!important;
  padding-right:2mm!important;
}

/* الصورتان: مربعتان تمامًا، ثابتتان داخل الخلية ولا يمكن أن تتجاوزا حد الجدول. */
.daily-evidence-images{
  width:100%!important;
  max-width:100%!important;
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,28mm))!important;
  justify-content:center!important;
  align-items:center!important;
  justify-items:center!important;
  gap:2mm!important;
  padding:2mm 0!important;
  margin:0 auto!important;
  overflow:hidden!important;
}

.daily-evidence-image-frame{
  width:28mm!important;
  height:28mm!important;
  max-width:28mm!important;
  max-height:28mm!important;
  aspect-ratio:1 / 1!important;
  flex:0 0 28mm!important;
  margin:0!important;
  overflow:hidden!important;
  border:1px solid #9eb7af!important;
  border-radius:2.6mm!important;
  background:#fff!important;
  box-sizing:border-box!important;
}

.daily-evidence-image-frame img{
  display:block!important;
  width:100%!important;
  height:100%!important;
  min-width:100%!important;
  min-height:100%!important;
  max-width:none!important;
  max-height:none!important;
  object-fit:cover!important;
  margin:0!important;
}

/* صورة واحدة تبقى مربعة ومتمركزة. */
.daily-evidence-images.single{
  grid-template-columns:28mm!important;
}
.daily-evidence-images.single .daily-evidence-image-frame{
  width:28mm!important;
  height:28mm!important;
  max-width:28mm!important;
  max-height:28mm!important;
}

@media print{
  /* مساحة أمان إضافية في الطباعة لمنع قص آخر بكسل من الجهة اليسرى. */
  .daily-preview .report-page-content{
    overflow:hidden!important;
  }

  .daily-table{
    width:calc(100% - 8mm)!important;
    max-width:calc(100% - 8mm)!important;
    margin-inline:4mm!important;
    border:1.2px solid #8fa6a1!important;
    box-shadow:inset 0 0 0 .25px #8fa6a1!important;
  }

  .daily-table th:nth-child(4),
  .daily-table td:nth-child(4){
    border-left:1.2px solid #8fa6a1!important;
    box-shadow:inset 1px 0 0 #8fa6a1!important;
    overflow:hidden!important;
  }

  .daily-evidence-images{
    grid-template-columns:repeat(2,minmax(0,27mm))!important;
    gap:1.8mm!important;
    padding:1.8mm 0!important;
    overflow:hidden!important;
  }

  .daily-evidence-image-frame,
  .daily-evidence-images.single .daily-evidence-image-frame{
    width:27mm!important;
    height:27mm!important;
    max-width:27mm!important;
    max-height:27mm!important;
    aspect-ratio:1 / 1!important;
    border-radius:2.3mm!important;
    box-shadow:none!important;
  }
}

/* ===== 2026-08-29 UX + repository fixes ===== */
.daily-repo-modal{
  position:fixed;
  inset:0;
  z-index:10020;
  background:rgba(16,46,61,.62);
  display:flex;
  justify-content:center;
  align-items:flex-start;
  padding:18px;
  overflow:auto;
}
.daily-repo-modal.hidden{display:none!important}
.daily-repo-dialog{
  width:min(820px,96vw);
  max-height:calc(100vh - 36px);
  overflow:auto;
  margin:0 auto;
  background:#fff;
  border-radius:20px;
  box-shadow:0 28px 80px rgba(0,0,0,.22);
}
.repo-list{padding-top:4px}
.repo-item small{display:block;color:#6b7f8c;margin-top:3px}

/* التقويم يظهر مباشرة أعلى مساحة التقرير بعد توجيه الصفحة إليه */
.daily-date-modal{
  align-items:flex-start!important;
  justify-items:center!important;
  overflow:auto;
  padding-top:18px!important;
}
.daily-date-modal .date-dialog{
  margin:0 auto;
  max-height:calc(100vh - 36px);
  overflow:auto;
}

@media(max-width:720px){
  .daily-repo-modal,.daily-date-modal{padding:10px!important}
  .daily-repo-dialog,.daily-date-modal .date-dialog{width:100%;max-height:calc(100vh - 20px)}
}

@media print{
  .daily-repo-modal{display:none!important}
}
