/* RESPONSIVE DESIGN FOR TABLET AND MOBILE */
/* Covers: exam.php, demo.php, and other pages */

.site-branding {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 auto 24px;
    width: max-content;
}

.site-branding a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.site-logo {
    max-height: 100px;
    width: auto;
    display: block;
}

.site-title {
    font-size: 1.9rem;
    font-weight: 700;
    white-space: nowrap;
    color: #edf2f7;
}

#header .site-branding {
    margin-bottom: 12px;
}

/* Success Page Styles */
.reg-number-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.reg-number-container p {
    margin: 0;
    font-size: 1.1rem;
    color: #2d3748;
}

#reg-number {
    font-family: 'Courier New', monospace;
    background: #f7fafc;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #cbd5e0;
    color: #2b6cb0;
}

.copy-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.copy-btn.copied {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

#options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 0;
    width: 100%;
    box-sizing: border-box;
}

#options label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    border-radius: 10px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.2s ease;
}

#options label:hover {
    background: #f7fbff;
    border-color: #c3dafe;
}

#options label span {
    flex: 1;
    min-width: 0;
    display: block;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

#options input[type="radio"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
}

#options label + br {
    display: none;
}

@media (max-width: 768px) {
    .site-branding {
        justify-content: center;
        margin-bottom: 16px;
        width: auto;
    }

    .site-logo {
        max-height: 60px;
    }

    .site-title {
        font-size: 1.25rem;
    }

    /* Success page responsive styles */
    .reg-number-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px;
    }

    .reg-number-container p {
        font-size: 1rem;
        text-align: center;
    }

    .copy-btn {
        align-self: center;
        padding: 10px 20px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .site-branding {
        margin-bottom: 14px;
    }

    .site-logo {
        max-height: 48px;
    }

    .site-title {
        font-size: 1rem;
    }

    /* Success page responsive styles */
    .reg-number-container {
        padding: 12px;
        gap: 8px;
    }

    .reg-number-container p {
        font-size: 0.95rem;
    }

    #reg-number {
        font-size: 0.9rem;
        padding: 3px 6px;
    }

    .copy-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

/* ===== TABLET VIEW (768px to 1024px) ===== */
@media (max-width: 1024px) {
    /* Reduce panel widths for tablets */
    #left-panel {
        width: 180px;
    }

    #right-panel {
        width: 180px;
    }

    #main {
        margin-left: 200px;
        margin-right: 200px;
        margin-bottom: 120px;
        padding: 20px;
    }

    #bottom {
        left: 200px;
        right: 200px;
    }

    #navigator {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }

    #question {
        font-size: 18px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #question h3 {
        font-size: 1.2em;
        word-wrap: break-word;
    }

    #options label {
        display: flex;
        align-items: center;
        font-size: 14px;
        padding: 10px 12px;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options label:hover {
        background: #f7fafc;
        border-color: #e2e8f0;
    }

    #options label span {
        flex: 1;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options input[type="radio"] {
        margin-right: 10px;
        flex-shrink: 0;
        transform: scale(1.2);
    }

    #header {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    #timer {
        font-size: 1.1em;
    }

    #reg {
        font-size: 13px;
    }

    #bottom button {
        padding: 8px 15px;
        font-size: 13px;
    }

    #subject {
        flex-basis: 100%;
        text-align: left;
    }
}

/* ===== MOBILE VIEW (max-width: 768px) ===== */
@media (max-width: 768px) {
    /* Layout: Stack vertically */
    body:has(#header) {
        display: flex;
        flex-direction: column;
        height: auto;
        margin-bottom: 400px;
        padding-bottom: 50px;
    }

    /* Header adjustments */
    #header {
        display: block;
        padding: 10px;
        text-align: center;
        border-bottom: 2px solid #667eea;
    }

    #timer {
        display: block;
        margin-bottom: 8px;
        font-size: 1.1em;
    }

    #reg {
        display: block;
        font-size: 12px;
        margin-bottom: 8px;
    }

    #subject {
        display: block;
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 8px;
        color: white;
    }

    #header button {
        width: 100%;
        margin-top: 8px;
        padding: 10px;
        font-size: 13px;
    }

    /* Hide left and right panels, show content-only layout */
    #left-panel {
        position: static;
        width: 100%;
        height: auto;
        padding: 8px;
        overflow: visible;
        border-right: none;
        border-bottom: 2px solid #e2e8f0;
        background: linear-gradient(180deg, #edf2f7 0%, #f7fafc 100%);
        margin-bottom: 10px;
        display: flex;
        gap: 8px;
        overflow-x: auto;
    }

    .subject-tab {
        padding: 8px 12px;
        margin: 0;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
        border-radius: 6px;
    }

    #main {
        margin: 10px;
        margin-left: 0;
        margin-right: 0;
        padding: 15px;
        border-radius: 10px;
        margin-bottom: 20px;
        flex: 1;
        overflow-y: auto;
        max-height: none;
        padding-bottom: 30px;
    }

    #question {
        font-size: 16px;
        margin-bottom: 20px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #question h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
        word-wrap: break-word;
    }

    #question p {
        font-size: 15px;
        line-height: 1.5;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options {
        margin: 15px 0;
    }

    #options label {
        display: flex;
        align-items: center;
        margin: 10px 0;
        padding: 10px;
        font-size: 14px;
        cursor: pointer;
        border-radius: 6px;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options label:hover {
        background: #f0f4ff;
        border-color: #667eea;
    }

    #options label span {
        flex: 1;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options input[type="radio"] {
        margin-right: 10px;
        flex-shrink: 0;
        margin-top: 0;
    }

    /* Navigator section */
    #right-panel {
        position: static;
        width: 100%;
        height: auto;
        padding: 10px;
        background: linear-gradient(180deg, #edf2f7 0%, #f7fafc 100%);
        border-left: none;
        border-top: 2px solid #e2e8f0;
        box-shadow: none;
        margin-bottom: 20px;
    }

    #right-panel::before {
        content: "Question Navigator";
        display: block;
        font-size: 13px;
        font-weight: 600;
        color: #2d3748;
        margin-bottom: 8px;
        text-align: center;
    }

    #navigator {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .nav-btn {
        width: 100%;
        height: 35px;
        font-size: 11px;
        padding: 5px;
        border-radius: 6px;
    }

    /* Bottom navigation */
    #bottom {
        position: static;
        display: flex;
        flex-direction: column;
        padding: 10px;
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-top: 3px solid #667eea;
        gap: 8px;
        margin-top: 10px;
        margin-bottom: 50px;
    }

    #bottom button {
        width: 100%;
        padding: 12px 15px;
        font-size: 14px;
        border-radius: 6px;
    }

    /* Optimized for small screens */
    #header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    body:has(#header) {
        height: auto;
    }
}

/* ===== SMALL MOBILE (max-width: 480px) ===== */
@media (max-width: 480px) {
    /* Extra small screens */
    body {
        font-size: 14px;
        margin-bottom: 450px;
        padding-bottom: 50px;
    }

    #header {
        padding: 8px;
    }

    #timer {
        font-size: 1em;
        margin-bottom: 5px;
    }

    #reg {
        font-size: 11px;
        margin-bottom: 5px;
    }

    #subject {
        font-size: 13px;
        margin-bottom: 5px;
    }

    #header button {
        padding: 8px;
        font-size: 12px;
    }

    #main {
        margin: 5px;
        padding: 10px;
        padding-bottom: 20px;
        border-radius: 8px;
        margin-bottom: 10px;
    }

    #question {
        font-size: 15px;
        margin-bottom: 15px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #question h3 {
        font-size: 1em;
        margin-bottom: 8px;
        word-wrap: break-word;
    }

    #question p {
        font-size: 14px;
        line-height: 1.4;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options label {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 8px 0;
        padding: 8px;
        font-size: 13px;
        cursor: pointer;
        border-radius: 6px;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options label:hover {
        background: #f0f4ff;
        border-color: #667eea;
    }

    #options label span {
        flex: 1;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options input[type="radio"] {
        margin-right: 10px;
        flex-shrink: 0;
        transform: scale(1.1);
    }

    #navigator {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
    }

    .nav-btn {
        height: 30px;
        font-size: 10px;
    }

    #bottom {
        padding: 8px;
        gap: 6px;
        margin-bottom: 50px;
    }

    #bottom button {
        padding: 10px 12px;
        font-size: 13px;
    }

    #left-panel {
        margin-bottom: 8px;
    }

    #right-panel {
        margin-bottom: 15px;
    }

    /* Scrollable subject tabs */
    #left-panel {
        overflow-x: scroll;
    }

    .subject-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ===== ORIENTATION: LANDSCAPE (Mobile) ===== */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
    #header {
        padding: 5px 10px;
    }

    #timer,
    #reg,
    #subject {
        font-size: 12px;
    }

    #main {
        padding: 10px;
        margin-bottom: 8px;
    }

    #question {
        font-size: 14px;
        margin-bottom: 12px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options label {
        display: flex;
        align-items: center;
        margin: 6px 0;
        padding: 6px;
        font-size: 13px;
        cursor: pointer;
        border-radius: 6px;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options label:hover {
        background: #f0f4ff;
        border-color: #667eea;
    }

    #options label span {
        flex: 1;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    #options input[type="radio"] {
        margin-right: 10px;
        flex-shrink: 0;
        transform: scale(1.1);
    }

    #navigator {
        grid-template-columns: repeat(6, 1fr);
    }

    #bottom {
        flex-direction: row;
        gap: 5px;
        padding: 8px;
    }

    #bottom button {
        flex: 1;
        padding: 6px 10px;
        font-size: 12px;
    }

    #right-panel::before {
        display: none;
    }
}

/* ===== TOUCH-FRIENDLY ADJUSTMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets for touch screens */
    button {
        min-height: 44px;
        padding: 12px 15px;
    }

    #options input[type="radio"] {
        width: 20px;
        height: 20px;
    }

    #options label {
        padding: 12px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .nav-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .subject-tab {
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Reduce hover effects on touch devices */
    button:hover {
        transform: none;
    }

    .nav-btn:hover {
        transform: none;
    }

    .subject-tab:hover {
        transform: none;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    #header,
    #left-panel,
    #right-panel,
    #bottom {
        display: none;
    }

    #main {
        margin: 0;
        box-shadow: none;
        border-radius: 0;
    }

    body {
        background: white;
    }
}

/* ===== RESULT PAGE RESPONSIVE STYLES ===== */

/* Tables - Mobile Responsive */
@media (max-width: 768px) {
    table {
        width: 100% !important;
        font-size: 13px !important;
    }

    table thead {
        display: none;
    }

    table tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px;
        overflow: hidden;
    }

    table td {
        display: block;
        padding: 10px !important;
        text-align: left !important;
        border-bottom: 1px solid #e2e8f0 !important;
    }

    table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #2d3748;
        display: block;
        margin-bottom: 5px;
    }

    table td:last-child {
        border-bottom: none !important;
    }

    table button {
        width: 100%;
        margin-top: 5px;
    }

    /* Modal Responsive */
    .modal-overlay {
        padding: 10px !important;
    }

    .modal-overlay > div {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        max-width: 100% !important;
        max-height: 85vh !important;
        width: 100% !important;
        margin: auto !important;
        border-radius: 10px !important;
    }

    .modal-overlay h3 {
        font-size: 1.2em;
        margin-bottom: 12px;
    }

    .modal-overlay h4 {
        font-size: 1em;
        margin-top: 15px;
        margin-bottom: 10px;
    }

    .modal-overlay > div > button {
        width: 100%;
        margin-top: 15px;
    }

    /* Question details in modal */
    .modal-overlay div[style*="border:1px solid"] {
        font-size: 13px !important;
        padding: 10px !important;
        margin: 10px 0 !important;
    }

    .modal-overlay ul {
        padding-left: 15px !important;
    }

    .modal-overlay ul li {
        font-size: 13px;
        margin: 5px 0 !important;
        padding: 5px 0 !important;
    }
}

/* Tables - Small Mobile */
@media (max-width: 480px) {
    table {
        font-size: 12px !important;
    }

    table td {
        padding: 8px !important;
    }

    table td::before {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .modal-overlay > div {
        padding: 12px !important;
    }

    .modal-overlay h3 {
        font-size: 1.1em;
        word-break: break-word;
    }

    .modal-overlay h4 {
        font-size: 0.95em;
    }

    .modal-overlay div[style*="border:1px solid"] {
        font-size: 12px !important;
        padding: 8px !important;
    }

    .modal-overlay p {
        font-size: 12px;
        line-height: 1.4;
        margin: 8px 0;
    }
}

/* Container - Tablet & Mobile */
@media (max-width: 1024px) {
    .container {
        max-width: 95% !important;
        margin: 10px auto !important;
        padding: 20px !important;
    }

    h1 {
        font-size: 1.8em !important;
    }

    h2 {
        font-size: 1.4em !important;
    }
}

@media (max-width: 768px) {
    .container {
        max-width: 100% !important;
        margin: 10px 0 !important;
        padding: 15px !important;
        border-radius: 0 !important;
        margin-bottom: 50px;
    }

    h1 {
        font-size: 1.6em !important;
        margin-bottom: 15px !important;
    }

    h2 {
        font-size: 1.2em !important;
        margin: 15px 0 10px !important;
    }

    p {
        font-size: 14px !important;
    }

    .buttons {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .buttons button {
        width: 100% !important;
        padding: 12px !important;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px !important;
    }

    h1 {
        font-size: 1.4em !important;
        margin-bottom: 12px !important;
    }

    h2 {
        font-size: 1.1em !important;
        margin: 12px 0 8px !important;
    }

    p {
        font-size: 13px !important;
    }

    .buttons {
        gap: 8px !important;
    }

    .buttons button {
        padding: 10px !important;
        font-size: 13px !important;
    }
}

/* ===== EXAM SETUP PAGE RESPONSIVE STYLES ===== */

/* Container - All Screen Sizes */
@media (max-width: 1024px) {
    .container {
        max-width: 95% !important;
        margin: 15px auto !important;
        padding: 20px !important;
        margin-bottom: 50px;
    }
}

@media (max-width: 768px) {
    .container {
        max-width: 100% !important;
        margin: 10px 0 !important;
        padding: 15px !important;
        border-radius: 10px !important;
        margin-bottom: 80px;
    }

    h1 {
        font-size: 1.6em !important;
        margin-bottom: 15px !important;
    }

    p {
        font-size: 14px !important;
        line-height: 1.5 !important;
        margin: 12px 0 !important;
    }

    /* List items responsive */
    .container ul {
        padding-left: 20px !important;
        margin: 15px 0 !important;
    }

    .container li {
        font-size: 14px !important;
        margin: 8px 0 !important;
        padding: 10px 12px !important;
        line-height: 1.5 !important;
    }

    /* Instructions List - Large text on mobile */
    .container ul li strong {
        color: #2d3748 !important;
        display: block !important;
        margin-bottom: 4px !important;
    }

    /* Buttons responsive */
    .buttons {
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 20px !important;
    }

    .buttons button {
        width: 100% !important;
        padding: 12px 15px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }

    body {
        margin-bottom: 100px;
        padding-bottom: 50px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px !important;
        margin: 8px 0 !important;
        margin-bottom: 100px;
        border-radius: 8px !important;
    }

    h1 {
        font-size: 1.4em !important;
        margin-bottom: 12px !important;
    }

    p {
        font-size: 13px !important;
        margin: 10px 0 !important;
    }

    .container ul {
        padding-left: 18px !important;
        margin: 12px 0 !important;
    }

    .container li {
        font-size: 13px !important;
        margin: 6px 0 !important;
        padding: 8px 10px !important;
        border-radius: 6px !important;
        word-break: break-word;
    }

    .container li strong {
        display: block;
        margin-bottom: 3px;
    }

    .buttons {
        gap: 8px !important;
        margin-top: 15px !important;
    }

    .buttons button {
        padding: 10px 12px !important;
        font-size: 13px !important;
        border-radius: 6px !important;
    }

    body {
        margin-bottom: 120px;
        padding-bottom: 60px;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .container {
        margin-bottom: 120px;
    }

    h1 {
        font-size: 1.2em !important;
    }

    .container li {
        font-size: 12px !important;
        padding: 6px 8px !important;
    }

    .buttons button {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    body {
        margin-bottom: 150px;
        padding-bottom: 70px;
    }
}

/* Register page and form spacing */
@media (max-width: 768px) {
    .container {
        margin-bottom: 120px !important;
    }

    form {
        margin-bottom: 40px !important;
    }

    input,
    select,
    button[type="submit"] {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .subject-selection {
        gap: 10px !important;
    }
}

@media (max-width: 480px) {
    .container {
        margin-bottom: 150px !important;
    }

    body {
        margin-bottom: 160px !important;
        padding-bottom: 80px !important;
    }
}
