/**
 * BCC Transcript Portal - Global Responsive Styles
 * Mobile-first approach with comprehensive device support
 * Applies to all pages across the portal
 */

/* ============================================
   BASE RESPONSIVE SETUP
   ============================================ */

/* Ensure proper rendering on all devices */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    min-width: 320px; /* Minimum supported screen width */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Responsive images and media */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Responsive tables */
table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
}

/* ============================================
   CONTAINER RESPONSIVE BREAKPOINTS
   ============================================ */

.container,
.container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    .container {
        max-width: 100%;
        padding-right: 10px;
        padding-left: 10px;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Extra extra large devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ============================================
   RESPONSIVE NAVIGATION
   ============================================ */

/* Mobile navigation improvements */
@media (max-width: 991.98px) {
    .navbar-collapse {
        width: 100%;
    }
    
    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: left;
    }
    
    /* Mobile menu toggle */
    .navbar-toggler {
        display: block;
        padding: 0.5rem 0.75rem;
        font-size: 1.25rem;
        line-height: 1;
        background-color: transparent;
        border: 1px solid rgba(255, 214, 0, 0.3);
        border-radius: 0.25rem;
        cursor: pointer;
    }
}

/* Hide mobile menu toggle on larger screens */
@media (min-width: 992px) {
    .navbar-toggler {
        display: none;
    }
}

/* ============================================
   RESPONSIVE FORMS
   ============================================ */

/* Base form responsiveness */
.form-control,
.form-select,
input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    font-size: 16px; /* Prevents zoom on iOS */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Extra small devices */
@media (max-width: 575.98px) {
    .form-control,
    .form-select,
    input,
    select,
    textarea {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label,
    label {
        font-size: 0.9rem;
    }
}

/* Small devices */
@media (min-width: 576px) and (max-width: 767.98px) {
    .form-control,
    .form-select {
        font-size: 15px;
        padding: 11px 13px;
    }
}

/* ============================================
   RESPONSIVE BUTTONS
   ============================================ */

.btn {
    display: inline-block;
    width: auto;
    white-space: nowrap;
    text-align: center;
    touch-action: manipulation;
    cursor: pointer;
    user-select: none;
}

/* Full-width buttons on mobile */
@media (max-width: 575.98px) {
    .btn-block-mobile {
        display: block;
        width: 100%;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 10px 16px;
    }
}

/* ============================================
   RESPONSIVE CARDS & PANELS
   ============================================ */

.card,
.panel,
.box {
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

@media (max-width: 767.98px) {
    .card,
    .panel,
    .box {
        border-radius: 6px;
        margin-bottom: 1rem;
    }
    
    .card-body,
    .panel-body {
        padding: 1rem;
    }
}

@media (max-width: 575.98px) {
    .card,
    .panel,
    .box {
        border-radius: 4px;
    }
    
    .card-body,
    .panel-body {
        padding: 0.75rem;
    }
}

/* ============================================
   RESPONSIVE TABLES
   ============================================ */

/* Make tables scrollable on small screens */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 4px;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Stack table on very small screens */
    .table-stack-mobile thead {
        display: none;
    }
    
    .table-stack-mobile tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 4px;
    }
    
    .table-stack-mobile td {
        display: block;
        text-align: right;
        padding: 0.5rem;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .table-stack-mobile td:last-child {
        border-bottom: none;
    }
    
    .table-stack-mobile td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: #666;
    }
}

/* ============================================
   RESPONSIVE GRID SYSTEM
   ============================================ */

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.col,
[class*="col-"] {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

/* Mobile-first columns */
.col {
    flex-basis: 0;
    flex-grow: 1;
    max-width: 100%;
}

/* Extra small devices (default, mobile-first) */
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }

/* Small devices and up */
@media (min-width: 576px) {
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
    .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
    .col-sm-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-sm-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-sm-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-sm-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
}

/* Medium devices and up */
@media (min-width: 768px) {
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
}

/* Large devices and up */
@media (min-width: 992px) {
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
    .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
    .col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-lg-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

/* Fluid typography scaling */
html {
    font-size: 16px; /* Base font size */
}

@media (max-width: 575.98px) {
    html { font-size: 14px; }
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    html { font-size: 15px; }
    h1 { font-size: 1.9rem; }
    h2 { font-size: 1.65rem; }
    h3 { font-size: 1.35rem; }
}

@media (min-width: 1200px) {
    html { font-size: 16px; }
}

@media (min-width: 1400px) {
    html { font-size: 17px; }
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

/* Display utilities for different screen sizes */
@media (max-width: 575.98px) {
    .d-none-mobile { display: none !important; }
    .d-block-mobile { display: block !important; }
}

@media (min-width: 576px) {
    .d-none-sm-up { display: none !important; }
}

@media (min-width: 768px) {
    .d-none-md-up { display: none !important; }
}

@media (min-width: 992px) {
    .d-none-lg-up { display: none !important; }
}

/* Text alignment utilities */
@media (max-width: 575.98px) {
    .text-center-mobile { text-align: center !important; }
    .text-left-mobile { text-align: left !important; }
    .text-right-mobile { text-align: right !important; }
}

/* Spacing utilities for mobile */
@media (max-width: 575.98px) {
    .p-mobile-0 { padding: 0 !important; }
    .p-mobile-1 { padding: 0.25rem !important; }
    .p-mobile-2 { padding: 0.5rem !important; }
    .p-mobile-3 { padding: 1rem !important; }
    
    .m-mobile-0 { margin: 0 !important; }
    .m-mobile-1 { margin: 0.25rem !important; }
    .m-mobile-2 { margin: 0.5rem !important; }
    .m-mobile-3 { margin: 1rem !important; }
}

/* ============================================
   RESPONSIVE MODALS & POPUPS
   ============================================ */

.modal,
.popup {
    max-width: 100%;
    max-height: 100vh;
}

@media (max-width: 767.98px) {
    .modal-dialog,
    .popup-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content,
    .popup-content {
        border-radius: 8px;
    }
}

@media (max-width: 575.98px) {
    .modal-dialog,
    .popup-dialog {
        margin: 0.25rem;
        max-width: calc(100% - 0.5rem);
    }
}

/* ============================================
   RESPONSIVE TOUCH INTERACTIONS
   ============================================ */

/* Larger touch targets for mobile */
@media (max-width: 767.98px) {
    button,
    a,
    .btn,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px; /* iOS recommended minimum */
        min-width: 44px;
    }
    
    /* Add spacing between interactive elements */
    button + button,
    .btn + .btn,
    a.btn + a.btn {
        margin-left: 8px;
    }
}

/* ============================================
   ORIENTATION-SPECIFIC STYLES
   ============================================ */

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    body {
        font-size: 14px;
    }
    
    .navbar {
        padding: 0.25rem 1rem;
    }
    
    .container {
        margin-top: 0.5rem;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.15rem; }
}

/* ============================================
   ACCESSIBILITY & SPECIAL MODES
   ============================================ */

/* High contrast mode */
@media (prefers-contrast: high) {
    button,
    .btn,
    a {
        border: 2px solid currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Auto dark mode can be enabled here if needed */
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    /* Hide non-essential elements */
    .navbar,
    .nav,
    .btn,
    .no-print,
    button {
        display: none !important;
    }
    
    /* Optimize for print */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
    }
    
    .container {
        max-width: none !important;
        width: 100% !important;
    }
    
    /* Page breaks */
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    table, figure {
        page-break-inside: avoid;
    }
}

/* ============================================
   DEVICE-SPECIFIC FIXES
   ============================================ */

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix iOS input zoom */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Fix iOS button appearance */
    button,
    .btn {
        -webkit-appearance: none;
        border-radius: 8px;
    }
}

/* Android-specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
    select {
        background-position: right 8px center;
    }
}

/* ============================================
   RESPONSIVE IFRAME & EMBED
   ============================================ */

.responsive-embed {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.responsive-embed::before {
    display: block;
    content: "";
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.responsive-embed iframe,
.responsive-embed embed,
.responsive-embed object,
.responsive-embed video {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ============================================
   RESPONSIVE IMAGES
   ============================================ */

.img-responsive,
.img-fluid {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Retina display support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Use 2x images for retina displays */
    .img-retina {
        image-rendering: -webkit-optimize-contrast;
    }
}

