/**
 * Exam Portal - Modern Table Styling
 * Premium Mobile Cards + Clean Desktop Tables
 */

/* ========================================
   STUDENT INFORMATION CARD (Mobile)
   ======================================== */
/* Student Info Table - Desktop */
.student-info-table tr {
    border-bottom: 1px solid #f0f0f0;
}

.student-info-table tr:last-child {
    border-bottom: none;
}

.student-info-table td:first-child {
    font-weight: 600;
    color: #6c757d;
    width: 40%;
}

.student-info-table td:last-child {
    font-weight: 600;
    color: #212529;
}

@media (max-width: 768px) {
    /* Change card order on mobile using flexbox */
    .content-wrapper {
        display: flex;
        flex-direction: column;
    }
    
    .content-wrapper > * {
        width: 100%;
    }
    
    /* Row with Student Info (has col-md-4) - Move to bottom */
    .content-wrapper > .row .col-md-4 {
        order: 999;
    }
    
    .content-wrapper > .row:has(.col-md-4) {
        order: 3;
    }
    
    /* Row with Submitted Exams (border-info card) - Move to top */
    .content-wrapper > .row:has(.card.border-info) {
        order: 1;
    }
    
    /* Row with Available Exams (border-success card) - Keep in middle */
    .content-wrapper > .row:has(.card.border-success) {
        order: 2;
    }
    
    /* Fallback: Direct card ordering */
    .card.border-primary {
        order: 3 !important;
    }
    
    .card.border-info {
        order: 1 !important;
    }
    
    .card.border-success {
        order: 2 !important;
    }
    
    /* Make student info row full width on mobile */
    .row .col-md-4,
    .row .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Student Info Card - Premium Style */
    .card.border-primary {
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        border: none;
        overflow: hidden;
        margin-bottom: 16px;
    }
    
    .card.border-primary .card-header {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
        color: #ffffff;
        font-weight: 700;
        font-size: 1.1rem;
        padding: 14px 16px;
    }
    .card.border-primary .card-header,
    .card.border-primary .card-header * {
        color: #ffffff !important;
    }
    
    .card.border-primary .card-body {
        padding: 0 !important;
    }
    
    .card.border-primary .student-info-table {
        margin: 0;
        width: 100%;
    }
    
    .card.border-primary .student-info-table tr {
        display: table-row !important;
        padding: 0;
        margin: 0;
        border-bottom: 1px dashed #eee;
        box-shadow: none;
        border-radius: 0;
    }
    
    .card.border-primary .student-info-table tr:last-child {
        border-bottom: none;
    }
    
    .card.border-primary .student-info-table {
        display: table;
        width: 100%;
    }
    
    .card.border-primary .student-info-table td {
        display: table-cell !important;
        padding: 10px 16px;
        border: none;
        vertical-align: middle;
        white-space: normal;
    }
    
    .card.border-primary .student-info-table td:first-child {
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        font-size: 0.75rem;
        color: #6c757d;
        width: 38%;
        text-align: left;
        white-space: nowrap;
        padding-right: 8px;
    }
    
    .card.border-primary .student-info-table td:last-child {
        font-weight: 600;
        font-size: 0.9rem;
        color: #212529;
        text-align: left; /* LEFT aligned for better readability */
        width: 62%;
        word-wrap: break-word;
        hyphens: none;
        padding-left: 8px;
    }
}

/* ========================================
   DESKTOP TABLE IMPROVEMENTS
   ======================================== */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 15px;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table td {
    padding: 15px;
    vertical-align: middle;
    border-color: #e9ecef;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ========================================
   PREMIUM MOBILE CARDS (< 768px)
   ======================================== */
@media (max-width: 768px) {
    /* Page background */
    body, .content-wrapper {
        background: #f8f9fa !important;
    }

    /* Hide table structure */
    .table thead {
        display: none !important;
    }
    
    .table,
    .table tbody {
        display: block;
        width: 100%;
    }
    
    /* Premium Card Design */
    .table tr {
        display: block;
        margin-bottom: 16px;
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        padding: 0;
        border: none;
        overflow: hidden;
        text-align: left !important;
    }
    
    .table tr:hover {
        transform: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
    
    /* Card Header - First td is the name (dark bg → white text for contrast) */
    .table td[data-label="Paper Name"] {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
        color: #ffffff;
        font-size: 1.1rem;
        font-weight: 700;
        padding: 14px 16px;
        border-bottom: none;
        display: block;
    }
    .table td[data-label="Paper Name"]::before,
    .table td[data-label="Paper Name"] * {
        color: #ffffff !important;
    }
    .table td[data-label="Paper Name"]::before {
        display: none; /* Hide label for header */
    }
    .table td[data-label="Paper Name"] strong {
        color: #ffffff;
        font-weight: 700;
    }
    
    /* Card Body - All other tds */
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 16px;
        border-bottom: 1px solid #f0f0f0;
        text-align: left;
    }
    
    .table td:last-child {
        border-bottom: none;
    }
    
    /* Labels - Small, grey, uppercase */
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        font-size: 0.8rem;
        color: #6c757d;
        flex: 0 0 40%;
    }
    
    /* Values - Bold, dark */
    .table td > * {
        font-weight: 600;
        color: #212529;
        text-align: right;
        flex: 1;
    }
    
    /* Subject - slightly smaller */
    .table td[data-label="Subject"] {
        padding: 8px 16px;
    }
    
    /* Badges */
    .table td .badge {
        font-size: 11px;
        padding: 4px 8px;
        font-weight: 600;
    }
    
    .table td small {
        display: block;
        margin-top: 2px;
        font-size: 10px;
        color: #6c757d;
    }
    
    /* Action Section - Full width with padding */
    .table td[data-label="Action"] {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px 16px 16px;
        background: #fafbfc;
    }
    
    .table td[data-label="Action"]::before {
        display: none; /* Hide "ACTION" label */
    }
    
    .table td[data-label="Action"] .btn {
        width: 100%;
        padding: 12px;
        margin-top: 0;
        border-radius: 8px;
        font-weight: 600;
        font-size: 14px;
        text-align: center;
    }
    
    .table td[data-label="Action"] .btn + .btn,
    .table td[data-label="Action"] .btn + a,
    .table td[data-label="Action"] a + .btn {
        margin-top: 8px;
    }
    
    .table td[data-label="Action"] br {
        display: none;
    }
}
