/* Import clean Arabic Font Cairo */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

/* Base reset and page setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #ffffff;
    color: #000000;
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    padding: 20px;
}

/* Container limits width and centers */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 10px;
}

/* Header layout */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000000;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.logo-container {
    order: 2; /* Puts the logo on the right side in RTL flow */
}

.univ-logo {
    max-height: 90px;
    width: auto;
    display: block;
}

.title-container {
    order: 1; /* Puts the title details to the left */
}

.title-container h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.title-container h2 {
    font-size: 16px;
    font-weight: 400;
    color: #000000;
}

/* Common Card style (Minimalist B&W) */
.card {
    background-color: #ffffff;
    border: 2px solid #000000;
    padding: 30px;
    margin-bottom: 30px;
}

.card h3 {
    font-size: 20px;
    margin-bottom: 15px;
    border-bottom: 1px solid #000000;
    padding-bottom: 10px;
}

.instruction-text {
    font-size: 14px;
    margin-bottom: 25px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #000000;
    background-color: #ffffff;
    color: #000000;
    font-family: inherit;
    outline: none;
    transition: background-color 0.2s, color 0.2s;
}

.form-group input:focus {
    background-color: #000000;
    color: #ffffff;
}

/* Button style */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid #000000;
    background-color: #ffffff;
    color: #000000;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn:hover {
    background-color: #000000;
    color: #ffffff;
}

.btn-print {
    margin-left: 10px;
}

.btn-back {
    background-color: #ffffff;
    color: #000000;
}

/* Error message style */
.error-message {
    margin-top: 15px;
    font-weight: 600;
    color: #000000;
    text-decoration: underline;
    display: none;
}

/* Results layout (Academic transcript) */
.results-card {
    border: 2px solid #000000;
}

.print-header {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 30px;
    border-bottom: 1px solid #000000;
    padding-bottom: 15px;
}

/* Official Transcript Styles */
.transcript {
    background-color: #ffffff;
    color: #000000;
}

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

.transcript-logo-right {
    order: 3;
}

.transcript-logo {
    max-height: 80px;
    width: auto;
}

.transcript-info-middle {
    order: 2;
    text-align: center;
}

.transcript-info-middle h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 5px;
}

.transcript-info-middle h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.transcript-info-middle p {
    font-size: 12px;
}

.transcript-date-left {
    order: 1;
    font-size: 12px;
    text-align: left;
}

.divider {
    border: none;
    border-top: 2px double #000000;
    margin: 15px 0;
}

/* Student metadata details list */
.student-details {
    margin-bottom: 25px;
    border: 1px solid #000000;
    padding: 15px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-item {
    flex: 1;
    font-size: 14px;
}

/* Table Style */
.grades-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 35px;
}

.grades-table th, 
.grades-table td {
    border: 1px solid #000000;
    padding: 10px;
    text-align: center;
    font-size: 13px;
}

.grades-table th {
    font-weight: 700;
    background-color: #ffffff;
}

.grades-table .course-name {
    text-align: right;
    font-weight: 600;
    font-size: 14px;
}

.exam-header-col {
    font-size: 12px;
}

.empty-cell {
    background-color: #ffffff;
    color: #000000;
}

/* Signatures layout at bottom */
.transcript-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
    padding-top: 20px;
}

.signature-box {
    text-align: center;
    flex: 1;
}

.signature-box p {
    font-size: 13px;
    font-weight: 600;
}

.sig-line {
    margin-top: 30px;
    font-weight: normal;
}

/* Footer Section */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 15px;
    border-top: 1px solid #000000;
    font-size: 12px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Print CSS */
@media print {
    body {
        padding: 0;
        background-color: #ffffff;
    }
    
    .container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .no-print {
        display: none !important;
    }
    
    .card {
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .transcript {
        border: none !important;
    }
    
    /* Hide the main query form when printing */
    #searchCard {
        display: none !important;
    }
    
    #resultsCard {
        display: block !important;
    }
}

/* ==========================================================================
   Responsive Styles for Mobile Devices (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* 1. Reduce body and container padding to maximize screen width */
    body {
        padding: 10px;
    }
    
    .container {
        padding: 5px;
    }
    
    .card {
        padding: 15px;
        margin-bottom: 20px;
    }

    /* 2. Re-arrange portal header layout to vertical */
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding-bottom: 15px;
    }
    
    .logo-container {
        order: -1; /* Place logo on top */
    }
    
    .title-container h1 {
        font-size: 20px;
    }
    
    .title-container h2 {
        font-size: 14px;
    }

    /* 3. Re-arrange transcript header layout to vertical */
    .transcript-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .transcript-logo-right {
        order: -1; /* Place logo on top */
    }
    
    .transcript-info-middle {
        order: 1;
    }
    
    .transcript-date-left {
        order: 2;
        text-align: center;
        margin-top: 5px;
    }

    /* 4. Make student metadata rows vertical to prevent squishing */
    .detail-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .detail-item {
        font-size: 13px;
        border-bottom: 1px dashed #cccccc;
        padding-bottom: 5px;
    }
    
    .detail-row:last-child .detail-item:last-child {
        border-bottom: none;
    }

    /* 5. Make the wide grades table horizontally scrollable */
    .grades-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* 6. Make signatures vertical */
    .transcript-footer {
        flex-direction: column;
        gap: 30px;
        margin-top: 35px;
    }
    
    .sig-line {
        margin-top: 15px;
    }

    /* 7. Optimize printing and control buttons layout */
    .print-header {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        margin-left: 0 !important;
    }
}
