
/* KOTAB EL BARAKA - ATTENDANCE V2 */

.attendance-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.attendance-fields .wide {
    grid-column: 1 / -1;
}

.attendance-fields label {
    font-weight: bold;
    color: #f0d58b;
}

.attendance-fields input,
.attendance-fields select {
    margin-top: 8px;
    color-scheme: dark;
}

/* الإحصائيات */

#dashboard .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    margin: 25px 0;
}

#dashboard .stat {
    background: linear-gradient(145deg, #103b30, #08251e);
    border: 1px solid #a88a42;
    border-radius: 15px;
    padding: 24px 12px;
    text-align: center;
    color: #ffffff;
}

#dashboard .stat strong {
    display: block;
    font-size: 36px;
    margin-bottom: 8px;
}

#totalChildren {
    color: #ecc24c;
}

#presentCount {
    color: #83dda1;
}

#absentCount {
    color: #f28c8c;
}

/* أزرار التحديد الجماعي */

.attendance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0;
}

#allPresent,
#allAbsent {
    flex: 1;
    padding: 12px;
    border-radius: 9px;
    cursor: pointer;
    font-weight: bold;
}

#allPresent {
    background: #184d34;
    border: 1px solid #459568;
    color: #a6edbd;
}

#allAbsent {
    background: #482829;
    border: 1px solid #ac5555;
    color: #ffb8b8;
}

/* لائحة الأطفال */

.children-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 25px 0;
}

.attendance-child {
    background: linear-gradient(145deg, #10372d, #0a2821);
    border: 1px solid #4d6b5c;
    border-radius: 15px;
    padding: 20px;
    min-width: 0;
    transition: border-color .2s;
}

.attendance-child:hover {
    border-color: #d5af51;
}

.attendance-child h3 {
    color: #f1d58a;
    font-size: 18px;
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #34574a;
}

/* حاضر أو غائب */

.status-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.status-controls button {
    padding: 12px;
    border-radius: 9px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}

.present-btn {
    background: #112f25;
    color: #8adba5;
    border: 1px solid #38784c;
}

.absent-btn {
    background: #322323;
    color: #ffb0b0;
    border: 1px solid #844545;
}

.present-btn.active {
    background: #237447;
    color: #ffffff;
    border-color: #7bd39a;
}

.absent-btn.active {
    background: #a13b3b;
    color: #ffffff;
    border-color: #ef9696;
}

/* مقدار الحفظ والملاحظات */

.attendance-child input,
.attendance-child textarea,
.attendance-fields textarea {
    box-sizing: border-box;
    display: block;
    width: 100%;
    padding: 13px;
    margin-top: 10px;
    border: 1px solid #536d5f;
    border-radius: 9px;
    background: #092820;
    color: #ffffff;
    font: inherit;
    outline: none;
}

.attendance-child textarea {
    resize: vertical;
    min-height: 75px;
}

.attendance-child input:focus,
.attendance-child textarea:focus {
    border-color: #ecc24c;
}

.attendance-child input::placeholder,
.attendance-child textarea::placeholder {
    color: #a3b8ae;
}

.attendance-child input:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* تأكيد التسجيل */

.demo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    margin: 20px 0;
}

.demo input {
    width: auto;
    accent-color: #ecc24c;
}

/* زر حفظ الحضور */

.gold,
#saveAttendance {
    display: block;
    width: 100%;
    background: linear-gradient(90deg, #d8aa32, #f8d36f);
    color: #102c25;
    padding: 16px;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: bold;
    cursor: pointer;
}

#saveAttendance:hover {
    background: #f4d67a;
}

#saveAttendance:disabled {
    opacity: .5;
    cursor: wait;
}

#attendanceResult {
    text-align: center;
    color: #ffdfa0;
    margin: 15px 0 0;
}

/* سجل الحضور */

.attendance-history {
    margin-top: 25px;
}

.attendance-history .intro {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

.attendance-history label {
    min-width: 180px;
}

.attendance-history td {
    white-space: normal;
    overflow-wrap: anywhere;
    min-width: 85px;
    padding: 15px 10px;
}

.attendance-history .scroll {
    overflow-x: auto;
}

.status-present {
    color: #83dda1;
    font-weight: bold;
}

.status-absent {
    color: #ff9696;
    font-weight: bold;
}

.edit-attendance {
    background: #ecc24c;
    color: #102c25;
    padding: 7px 15px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-weight: bold;
}

/* زر تحميل CSV */

#exportCSV {
    background: #15533c;
    color: #ffffff;
    border: 1px solid #65a47c;
    padding: 12px 20px;
    border-radius: 9px;
    cursor: pointer;
    font-weight: bold;
}

#exportCSV:hover {
    background: #216b4d;
}

/* الرسائل */

#message:not([hidden]) {
    padding: 12px 16px;
    background: #143a30;
    color: #ffdfa0;
    border: 1px solid #a88a42;
    border-radius: 10px;
    overflow-wrap: anywhere;
}

#message[data-error="true"] {
    color: #ffbbbb;
}

#empty {
    margin-top: 16px;
    text-align: center;
    color: #b7c9be;
}

/* Mobile responsive */

@media (max-width: 700px) {

    .attendance-fields {
        grid-template-columns: 1fr;
    }

    .children-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    #dashboard .stats {
        gap: 7px;
    }

    #dashboard .stat {
        padding: 18px 5px;
        font-size: 12px;
    }

    #dashboard .stat strong {
        font-size: 28px;
    }

    .attendance-child {
        padding: 15px;
    }

    .attendance-history label {
        min-width: 0;
        width: 100%;
    }

    #exportCSV {
        width: 100%;
    }

}
/* تنسيق خانة الملاحظات */

#attendanceForm #notes {
    display: block;
    width: 100%;
    min-height: 130px;
    padding: 15px;
    margin-top: 8px;
    box-sizing: border-box;
    background: #0d2b23;
    border: 1px solid #526b4b;
    border-radius: 10px;
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    direction: rtl;
    text-align: right;
    resize: vertical;
}

#attendanceForm #notes::placeholder {
    color: #a5b8b0;
}

#attendanceForm #notes:focus {
    outline: none;
    border-color: #e8bd50;
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    width: 100%;
    padding-left: 50px !important;
    box-sizing: border-box;
}

#togglePassword {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #155747 !important;
    padding: 5px !important;
    width: auto !important;
    cursor: pointer;
}

/* Correction tableau mobile */

@media (max-width: 768px) {

    .attendance-history .scroll {
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .attendance-history table {
        min-width: 750px !important;
        border-collapse: collapse;
    }

    .attendance-history th,
    .attendance-history td {
        white-space: nowrap !important;
        font-size: 13px;
        padding: 10px 12px;
        text-align: center;
    }

    .attendance-history td:nth-child(3) {
        min-width: 110px;
        direction: ltr;
    }

    .attendance-history .edit-attendance {
        width: auto !important;
        min-width: 75px;
        padding: 8px 15px;
        font-size: 13px;
        white-space: nowrap;
        border-radius: 7px;
    }
}


/* PDF - Liste de présence */

@page {
    size: A4 landscape;
    margin: 12mm;
}

@media print {

    html, body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    body > header,
    body > footer,
    main > :not(#dashboard),
    #dashboard > :not(.attendance-history),
    #exportCSV,
    .attendance-history .intro label,
    .attendance-history th:last-child,
    .attendance-history td:last-child {
        display: none !important;
    }

    main, #dashboard,
    .attendance-history {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        border: none !important;
        box-shadow: none !important;
    }

    .attendance-history .intro {
        display: block !important;
        text-align: center;
        margin-bottom: 25px;
    }

    .attendance-history h2 {
        color: #155747 !important;
        font-size: 24px;
    }

    .attendance-history h2::before {
        content: "كُتّاب البركة";
        display: block;
        font-size: 30px;
        margin-bottom: 15px;
    }

    .attendance-history .scroll {
        overflow: visible !important;
    }

    .attendance-history table {
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: collapse;
        display: table !important;
    }

    .attendance-history thead {
        display: table-header-group !important;
    }

    .attendance-history tr {
        break-inside: avoid;
    }

    .attendance-history th {
        background: #155747 !important;
        color: #ffffff !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .attendance-history th,
    .attendance-history td {
        border: 1px solid #999999;
        padding: 10px;
        font-size: 12px;
        text-align: center;
        white-space: normal !important;
    }

    .attendance-history td {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .attendance-history td:nth-child(3) {
        white-space: nowrap !important;
    }
}

/* Logo officiel dans le PDF */

@media print {

    body > header {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        position: static !important;
        background: #ffffff !important;
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        padding: 0 0 20px !important;
        margin: 0 0 20px !important;
    }

    body > header > :not(.brand) {
        display: none !important;
    }

    body > header .brand {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        margin: 0 auto !important;
        text-decoration: none !important;
        width: auto !important;
    }

    header .brand svg {
        width: 65px !important;
        height: 65px !important;
    }

    header .brand span {
        font-size: 28px !important;
    }

    header .brand small {
        font-size: 12px !important;
    }

    .attendance-history h2::before,
    .attendance-history h2::after {
        content: none !important;
        display: none !important;
    }

    body > footer {
        display: none !important;
    }
}

.admin-navigation {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0 30px;
}

.admin-navigation a {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #145548;
  color: #ffffff;
  border: 1px solid #c5a34f;
  border-radius: 12px;
  padding: 20px 10px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
  transition: 0.3s;
}

.admin-navigation a:hover {
  background: #e9bc50;
  color: #092b24;
}

@media (max-width: 768px) {
  .admin-navigation {
    grid-template-columns: repeat(2, 1fr);
  }
}