/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --secondary: #1a5f7a;
    --success: #28a745;
    --warning: #f39c12;
    --light: #f8f9fa;
    --dark: #2c3e50;
    --text: #333;
    --border: #dee2e6;
    --shadow: 0 2px 15px rgba(0,0,0,0.1);
    --radius: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles - FIXED LOGO SIZE */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, #1a2530 100%);
    color: white;
    padding: 12px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

/* FIXED: Proper logo size */
.site-logo {
    height: 50px !important; /* Reduced from 70px */
    width: auto;
    max-width: 140px; /* Reduced from 180px */
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.text-logo {
    background: var(--secondary);
    padding: 10px 15px;
    border-radius: 6px;
    text-align: center;
    min-width: 150px;
}

.text-logo h1 {
    font-size: 20px;
    color: white;
    margin: 0;
    font-weight: bold;
}

.text-logo p {
    font-size: 11px;
    color: #bdc3c7;
    margin: 3px 0 0 0;
}

.logo-text {
    flex: 1;
    min-width: 0;
}

.logo-text h1 {
    font-size: 22px;
    font-weight: 700;
    color: white;
    margin-bottom: 3px;
    line-height: 1.2;
}

.logo-text .tagline {
    font-size: 13px;
    color: #bdc3c7;
    font-style: italic;
    margin: 0;
}

.contact-info {
    text-align: right;
    flex-shrink: 0;
}

.contact-info p {
    margin: 6px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

.contact-info i {
    color: #3498db;
    min-width: 16px;
    font-size: 14px;
}

/* Main Content */
.main-content {
    padding: 25px 0;
    min-height: calc(100vh - 130px);
}

/* Search Section */
.search-section {
    margin: 15px auto;
    max-width: 800px;
}

.search-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    position: relative;
}

.search-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
}

.search-card h2 {
    color: var(--primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--secondary);
}

.search-form {
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--dark);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    transition: all 0.3s;
    background: var(--light);
}

.form-group input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.15);
    background: white;
}

/* Buttons */
.btn-search, .btn-print {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-search {
    background: linear-gradient(135deg, var(--secondary), #2980b9);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 95, 122, 0.2);
}

.btn-print {
    background: linear-gradient(135deg, var(--success), #219653);
    color: white;
    padding: 10px 20px;
    border: 2px solid transparent;
}

.btn-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.2);
    border-color: var(--success);
}

/* Result Section */
.result-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 2px solid var(--border);
}

.student-photo {
    text-align: center;
    margin-bottom: 20px;
}

.student-photo-img {
    width: 150px;
    height: 180px;
    object-fit: cover;
    border: 3px solid var(--secondary);
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    background: white;
    padding: 3px;
}

.result-table {
    margin: 18px 0;
    background: var(--light);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.result-table table {
    width: 100%;
    border-collapse: collapse;
}

.result-table tr {
    border-bottom: 1px solid var(--border);
}

.result-table tr:last-child {
    border-bottom: none;
}

.result-table td {
    padding: 14px 18px;
    vertical-align: middle;
    font-size: 14px;
}

.result-table td:first-child {
    width: 35%;
    font-weight: 600;
    color: var(--primary);
    border-right: 1px solid var(--border);
    background: rgba(26, 95, 122, 0.05);
}

.result-table td i {
    width: 18px;
    text-align: center;
    color: var(--secondary);
}

.cgpa {
    color: var(--success);
    font-weight: bold;
    font-size: 16px;
    background: #d4edda;
    padding: 5px 12px;
    border-radius: 15px;
    display: inline-block;
}

/* QR Code Container - AFTER result table */
.qr-code-container {
    text-align: center;
    margin: 30px auto 25px;
    padding: 25px;
    border: 2px solid var(--secondary);
    border-radius: 10px;
    background: white;
    max-width: 380px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.qr-code {
    width: 180px !important;
    height: 180px !important;
    margin: 0 auto 15px !important;
    display: block !important;
    border: 1px solid #ddd;
    padding: 8px;
    background: white;
    border-radius: 4px;
}

.qr-text {
    font-size: 15px;
    color: var(--secondary);
    margin-top: 12px;
    font-weight: 600;
}

.qr-note {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-style: italic;
}

.qr-note i {
    color: var(--secondary);
    margin-right: 5px;
}

/* QR Code for Print (AFTER result table) */
.qr-code-print {
    display: none;
}

.print-qr-container {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    border: 2px solid var(--secondary);
    border-radius: 8px;
    background: white;
    page-break-inside: avoid;
}

.qr-code-print-img {
    width: 150px !important;
    height: 150px !important;
    display: block;
    margin: 0 auto 10px !important;
    border: 1px solid #666;
    padding: 6px;
    background: white;
    border-radius: 4px;
}

.qr-label {
    font-size: 13px !important;
    color: #1a5f7a !important;
    font-weight: bold !important;
    margin: 10px 0 0 0 !important;
    letter-spacing: 0.5px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Print Footer */
.print-footer {
    display: none;
}

.print-footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8px;
    color: #666;
    line-height: 1.2;
}

.official-note {
    color: #1a5f7a !important;
    font-size: 8px !important;
}

/* Print Header */
.print-header {
    display: none;
}

.print-header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 8px;
}

.print-logo img {
    height: 40px !important;
    width: auto !important;
    max-width: 100px !important;
    filter: none !important;
}

.print-header-text {
    text-align: center;
    flex: 1;
}

.print-header-text h1 {
    font-size: 18px;
    font-weight: bold;
    color: #1a5f7a;
    margin: 0 0 2px 0;
}

.print-address {
    font-size: 8px;
    color: #666;
    margin: 0 0 4px 0;
}

.print-document-title {
    font-size: 11px;
    font-weight: bold;
    color: #000;
    text-transform: uppercase;
    margin: 4px 0 0 0;
    padding-top: 4px;
    border-top: 1px solid #ddd;
}

.print-header-border {
    border-top: 2px solid #1a5f7a;
    margin-top: 4px;
}

/* No Result */
.no-result {
    text-align: center;
    padding: 30px 25px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    margin-top: 25px;
    border-left: 4px solid var(--warning);
}

.no-result i {
    font-size: 40px;
    color: var(--warning);
    margin-bottom: 15px;
    opacity: 0.8;
}

.no-result h3 {
    color: var(--dark);
    margin-bottom: 12px;
    font-size: 18px;
}

.no-result p {
    color: #856404;
    font-size: 14px;
    max-width: 500px;
    margin: 0 auto;
}

/* Footer */
.footer {
    background: var(--dark);
    color: white;
    text-align: center;
    padding: 15px 0;
    margin-top: auto;
    border-top: 4px solid var(--secondary);
}

.footer p {
    margin: 5px 0;
}

.footer-address {
    font-size: 13px;
    opacity: 0.9;
    color: #bdc3c7;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .logo {
        flex-direction: column;
        text-align: center;
        gap: 12px;
        width: 100%;
    }
    
    .logo-text {
        border-top: 1px solid rgba(255,255,255,0.2);
        padding-top: 12px;
        margin-top: 12px;
    }
    
    .contact-info {
        text-align: center;
        width: 100%;
    }
    
    .contact-info p {
        justify-content: center;
    }
    
    .search-card {
        padding: 20px;
    }
    
    .search-card h2 {
        font-size: 20px;
    }
    
    .result-table td {
        padding: 12px 15px;
        font-size: 13px;
    }
    
    .student-photo-img {
        width: 130px;
        height: 160px;
    }
    
    .qr-code-container {
        padding: 20px;
        max-width: 320px;
    }
    
    .qr-code {
        width: 160px !important;
        height: 160px !important;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-search, .btn-print {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .site-logo {
        height: 45px !important;
        max-width: 120px !important;
    }
    
    .logo-text h1 {
        font-size: 18px;
    }
    
    .logo-text .tagline {
        font-size: 12px;
    }
    
    .search-card {
        padding: 18px 15px;
    }
    
    .result-table td {
        padding: 10px 12px;
        display: block;
        width: 100%;
        border: none;
    }
    
    .result-table td:first-child {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 5px;
        margin-bottom: 5px;
    }
    
    .result-table tr {
        display: block;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 2px solid var(--border);
    }
    
    .student-photo-img {
        width: 120px;
        height: 150px;
    }
    
    .qr-code-container {
        padding: 18px 15px;
    }
}

/* PRINT STYLES - QR AFTER RESULT TABLE */
@media print {
    @page {
        margin: 0.5in;
        size: A4 portrait;
    }
    
    body {
        background: white !important;
        color: #000000 !important;
        font-family: "Times New Roman", "Arial", sans-serif !important;
        font-size: 11pt !important;
        line-height: 1.3 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Hide website elements */
    .header, .footer, .action-buttons, .search-form, 
    .search-card h2, .no-result, .btn-print,
    .logo-text .tagline, .contact-info,
    .fas, .fa, .btn-search, .qr-code-container {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* Show print elements - QR code is part of body content */
    .print-header, .print-footer, .qr-code-print {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Print Header */
    .print-header {
        border-bottom: 3px double #1a5f7a !important;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
        page-break-after: avoid !important;
    }
    
    .print-header-content {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 8px !important;
    }
    
    .print-logo img {
        height: 40px !important;
        width: auto !important;
        max-width: 100px !important;
        filter: none !important;
    }
    
    .print-header-text {
        text-align: center !important;
        flex-grow: 1 !important;
    }
    
    .print-header-text h1 {
        font-size: 16pt !important;
        font-weight: bold !important;
        color: #1a5f7a !important;
        margin: 0 0 2px 0 !important;
    }
    
    .print-address {
        font-size: 8pt !important;
        color: #666666 !important;
        margin: 0 0 3px 0 !important;
    }
    
    .print-document-title {
        font-size: 10pt !important;
        font-weight: bold !important;
        color: #000000 !important;
        text-transform: uppercase !important;
        margin: 3px 0 0 0 !important;
        padding-top: 3px !important;
        border-top: 1px solid #dddddd !important;
    }
    
    /* Search Card */
    .search-card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        page-break-inside: avoid !important;
    }
    
    /* Student Photo */
    .student-photo {
        text-align: center !important;
        margin: 10px 0 15px 0 !important;
        page-break-inside: avoid !important;
    }
    
    .student-photo-img {
        width: 110px !important;
        height: 135px !important;
        border: 1.5px solid #000000 !important;
        border-radius: 2px !important;
        box-shadow: none !important;
        padding: 2px !important;
        background: white !important;
    }
    
    /* Result Table */
    .result-table {
        background: transparent !important;
        border: 1px solid #000000 !important;
        border-radius: 0 !important;
        margin: 10px 0 15px 0 !important;
        page-break-inside: avoid !important;
    }
    
    .result-table table {
        border-collapse: collapse !important;
        font-size: 9pt !important;
    }
    
    .result-table tr {
        border-bottom: 0.5pt solid #000000 !important;
    }
    
    .result-table tr:last-child {
        border-bottom: none !important;
    }
    
    .result-table td {
        padding: 6px 8px !important;
        vertical-align: middle !important;
        border-right: 0.5pt solid #dddddd !important;
    }
    
    .result-table td:first-child {
        width: 35% !important;
        font-weight: bold !important;
        color: #000000 !important;
        background: #f0f0f0 !important;
        border-right: 0.5pt solid #000000 !important;
    }
    
    .result-table td i {
        display: none !important;
    }
    
    .cgpa {
        color: #000000 !important;
        font-weight: bold !important;
        background: #f0f0f0 !important;
        padding: 2px 6px !important;
        border-radius: 1px !important;
        border: 0.5pt solid #000000 !important;
    }
    
    /* QR Code in Body (AFTER result table) */
    .print-qr-container {
        border: 2pt solid #1a5f7a !important;
        margin: 20px auto 25px !important;
        padding: 15px !important;
        background: white !important;
        page-break-inside: avoid !important;
        max-width: 280px !important;
        text-align: center !important;
    }
    
    .qr-code-print-img {
        width: 140px !important;
        height: 140px !important;
        border: 1pt solid #000000 !important;
        padding: 5px !important;
        background: white !important;
        display: block !important;
        margin: 0 auto 10px !important;
    }
    
    .qr-label {
        font-size: 11pt !important;
        color: #1a5f7a !important;
        font-weight: bold !important;
        margin: 8px 0 0 0 !important;
    }
    
    /* Print Footer */
    .print-footer {
        position: fixed !important;
        bottom: 0.3in !important;
        left: 0.5in !important;
        right: 0.5in !important;
        border-top: 1pt solid #666666 !important;
        padding-top: 5px !important;
        background: white !important;
        z-index: 9999 !important;
        page-break-inside: avoid !important;
    }
    
    .print-footer-content {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        font-size: 7pt !important;
        color: #666666 !important;
        line-height: 1.1 !important;
    }
    
    .footer-left, .footer-right {
        flex: 1 !important;
    }
    
    .footer-left {
        text-align: left !important;
    }
    
    .footer-right {
        text-align: right !important;
    }
    
    .print-footer strong {
        color: #1a5f7a !important;
        font-weight: bold !important;
    }
    
    /* Ensure single page */
    .result-section {
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        margin-bottom: 70px !important;
        min-height: auto !important;
        padding-top: 5px !important;
        margin-top: 5px !important;
    }
    
    /* Remove colors */
    * {
        color: #000000 !important;
        background: transparent !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }
    
    /* Force single page */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }
    
    .main-content {
        padding: 0 !important;
        min-height: auto !important;
    }
    
    /* No page breaks */
    .search-card, .result-table, .student-photo, .print-qr-container {
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
    }
    
    /* Watermark */
    body::after {
        content: "BAMMT OFFICIAL";
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-45deg);
        font-size: 60pt;
        color: rgba(26, 95, 122, 0.05) !important;
        z-index: -1;
        pointer-events: none;
        white-space: nowrap;
        font-weight: bold;
    }
}