/* ========================================
   RESPONSIVE ENHANCEMENTS
   Mobile-First Responsive Design
   ======================================== */

/* Base Mobile Styles (320px+) */
@media (max-width: 480px) {
    
    /* Typography Adjustments */
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* Icon Button Mobile */
    .btn-icon {
        width: 32px;
        height: 32px;
        margin-right: 0.5rem;
        border-width: 2px;
    }
    
    .btn-icon i {
        font-size: 1.125rem;
    }
    
    /* Back Button Mobile (if text version is used) */
    .btn-back {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        margin-right: 0.5rem;
        min-width: auto;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .btn-back i {
        font-size: 0.875rem;
    }
    
    /* Navigation Brand with Back Button */
    .navbar__brand {
        display: flex;
        align-items: center;
        flex: 1;
        min-width: 0;
        gap: 0.5rem;
    }
    
    .navbar__brand h2 {
        font-size: 0.9375rem;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }
    
    /* Navigation Menu Items with Icons */
    .navbar__link {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .navbar__link i {
        font-size: 1.125rem;
    }
    
    .navbar__menu .btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.125rem !important; }
    h4 { font-size: 1rem !important; }
    
    /* Container Adjustments */
    .container {
        margin: 0.5rem auto;
        padding: 1rem;
        border-radius: 15px;
    }
    
    /* Prevent content overlap with sticky navbar */
    body.dashboard-page .container {
        padding-top: 1rem;
        margin-top: 0;
    }
    
    body .container {
        margin-top: 0.5rem;
    }
    
    /* Page Header Mobile */
    .page-header {
        padding: 1rem 0;
        margin-bottom: 1rem;
        animation: slideDown 0.4s ease-out;
    }
    
    .page-header h1 {
        font-size: 1.375rem !important;
        margin-bottom: 0.25rem;
    }
    
    .page-header p {
        font-size: 0.8125rem;
    }
    
    /* Smooth content loading */
    .container > * {
        animation: fadeInUp 0.4s ease-out;
        animation-fill-mode: both;
    }
    
    .container > *:nth-child(1) {
        animation-delay: 0.1s;
    }
    
    .container > *:nth-child(2) {
        animation-delay: 0.2s;
    }
    
    .container > *:nth-child(3) {
        animation-delay: 0.3s;
    }
    
    .container > *:nth-child(4) {
        animation-delay: 0.4s;
    }
    
    /* Card Adjustments */
    .card {
        padding: 1rem;
        border-radius: 12px;
        margin-bottom: 1rem;
    }
    
    .card__header {
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .card__title {
        font-size: 1.125rem;
    }
    
    /* Button Adjustments */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Form Adjustments */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.625rem 0.875rem;
        font-size: 1rem;
        border-width: 2px;
    }
    
    /* Table Adjustments */
    .table-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table {
        font-size: 0.8125rem;
        border-width: 2px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }
    
    .table th {
        font-size: 0.75rem;
        border-bottom-width: 2px;
    }
    
    /* Modal Adjustments */
    .modal__content {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .modal__header,
    .modal__body,
    .modal__footer {
        padding: 1rem;
    }
    
    .modal__title {
        font-size: 1.125rem;
    }
    
    .modal__footer {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal__footer .btn {
        width: 100%;
    }
    
    /* Confirm Dialog Mobile */
    .confirm-dialog {
        max-width: 100%;
        border-radius: 15px;
        margin: 1rem;
    }
    
    .confirm-dialog__icon {
        width: 60px;
        height: 60px;
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .confirm-dialog__message {
        font-size: 0.9375rem;
        margin-bottom: 1.5rem;
    }
    
    .confirm-dialog__actions {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .confirm-dialog__actions .btn {
        width: 100%;
        min-width: auto;
    }
    
    /* Grid Adjustments */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* Navigation Adjustments */
    .navbar__container {
        padding: 0.625rem 0.75rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }
    
    .navbar__brand {
        flex: 1;
        min-width: 0;
    }
    
    .navbar__brand h2 {
        font-size: 0.9375rem;
    }
    
    .navbar__toggle {
        flex-shrink: 0;
        padding: 0.375rem;
    }
    
    .navbar__menu {
        top: 52px;
        padding: 0;
        display: flex;
        opacity: 0;
    }
    
    .navbar__menu--open {
        padding: 0.75rem;
        opacity: 1;
    }
    
    .navbar__link {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Dashboard Header */
    .dashboard-header {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
        border-radius: 12px;
    }
    
    .dashboard-header h1 {
        font-size: 1.5rem !important;
    }
    
    .dashboard-header p {
        font-size: 0.875rem;
    }
    
    /* Student Navbar Mobile Fix */
    .student-navbar .navbar__container {
        padding: 0.625rem 0.75rem;
        gap: 0.75rem;
    }
    
    .student-navbar .navbar__brand {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .student-navbar .navbar__brand h2 {
        font-size: 1rem;
        line-height: 1.2;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .student-navbar .navbar__toggle {
        padding: 0.375rem;
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }
    
    .student-navbar .navbar__toggle-icon {
        width: 22px;
    }
    
    .student-navbar .navbar__toggle-icon::before,
    .student-navbar .navbar__toggle-icon::after {
        width: 22px;
    }
    
    /* Stat Cards */
    .stat-card {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        border-width: 2px;
    }
    
    .stat-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-value--small {
        font-size: 1.125rem;
    }
    
    /* Nav Cards */
    .nav-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .nav-card {
        padding: 1.25rem;
        border-radius: 12px;
        border-width: 2px;
    }
    
    .nav-card__icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        border-width: 2px;
    }
    
    .nav-card__icon svg {
        width: 24px;
        height: 24px;
    }
    
    .nav-card h4 {
        font-size: 1rem;
    }
    
    .nav-card p {
        font-size: 0.8125rem;
    }
    
    /* Toast Notifications */
    .toast {
        bottom: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        min-width: auto;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Badge Adjustments */
    .badge {
        padding: 0.25rem 0.625rem;
        font-size: 0.75rem;
        border-width: 2px;
    }
    
    /* Login Page */
    .login-container {
        padding: 0.75rem;
    }
    
    .login-card {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .login-card h1 {
        font-size: 1.375rem !important;
    }
    
    .login-card h2 {
        font-size: 1.125rem !important;
    }
    
    /* Admin Header */
    .admin-header {
        padding: 1rem 0;
        margin-bottom: 1.5rem;
    }
    
    .admin-header h1 {
        font-size: 1.375rem !important;
        margin-bottom: 0.25rem;
    }
    
    .admin-header p {
        font-size: 0.8125rem;
    }
    
    .admin-header .container {
        padding: 0 1rem;
    }
    
    .admin-header .flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .admin-header .flex > div:first-child {
        width: 100%;
    }
    
    .admin-header .flex .gap-2 {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .admin-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Toolbar Mobile */
    .toolbar {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .toolbar .search-box {
        width: 100%;
    }
    
    .toolbar .btn {
        width: 100%;
    }
    
    /* Tab Navigation Mobile */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        -ms-overflow-style: auto;
        gap: 0.25rem;
        padding-bottom: 0;
        margin-bottom: 1rem;
    }
    
    .tabs::-webkit-scrollbar {
        height: 3px;
    }
    
    .tabs::-webkit-scrollbar-track {
        background: var(--border-color);
    }
    
    .tabs::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 3px;
    }
    
    .tab {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Strand Cards Mobile */
    .strand-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        margin-top: 1rem;
    }
    
    .strand-card {
        padding: 1.5rem;
        border-width: 2px;
    }
    
    .strand-card__icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .strand-card h3 {
        font-size: 1.25rem;
    }
    
    .strand-card p {
        font-size: 0.8125rem;
    }
    
    /* Table Actions Mobile */
    .table-actions {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .table-actions .btn {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }
    
    /* Form Row Mobile */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* Utility Spacing */
    .mt-4 { margin-top: 1.5rem; }
    .mb-4 { margin-bottom: 1.5rem; }
    .p-4 { padding: 1.5rem; }
    
    /* Flex Utilities Mobile */
    .flex.gap-2 {
        gap: 0.5rem;
    }
    
    .flex.justify-between {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Tablet Styles (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    
    /* Container */
    .container {
        padding: 1.5rem;
        margin: 1rem auto;
    }
    
    /* Grid Layouts */
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Strand Grid Tablet */
    .strand-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.25rem;
    }
    
    /* Cards */
    .card {
        padding: 1.25rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1.25rem;
    }
    
    /* Admin Header Tablet */
    .admin-header .flex {
        flex-direction: row;
        align-items: center;
    }
    
    .admin-header .flex .gap-2 {
        flex-direction: row;
        width: auto;
    }
    
    .admin-header .btn {
        width: auto;
    }
    
    /* Toolbar Tablet */
    .toolbar {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .toolbar .search-box {
        max-width: 300px;
    }
    
    .toolbar .btn {
        width: auto;
    }
    
    /* Navigation */
    .navbar__container {
        padding: 1rem 1.5rem;
    }
    
    /* Dashboard */
    .dashboard-header {
        padding: 1.5rem;
    }
    
    .dashboard-header h1 {
        font-size: 2rem !important;
    }
    
    /* Nav Grid */
    .nav-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Modal */
    .modal__content {
        width: 90%;
        border-radius: 15px;
    }
    
    /* Table */
    .table th,
    .table td {
        padding: 0.75rem 0.625rem;
    }
}

/* Desktop Small (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    
    .container {
        padding: 1.75rem;
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .nav-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Landscape Mobile (max-height: 500px) */
@media (max-height: 500px) and (orientation: landscape) {
    
    .modal__content {
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .dashboard-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .dashboard-header h1 {
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem;
    }
    
    .dashboard-header p {
        font-size: 0.875rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .navbar__container {
        padding: 0.5rem 1rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
    }
    
    .navbar__link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .table tbody tr {
        cursor: pointer;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .nav-card:hover {
        transform: none;
    }
    
    /* Active states for touch */
    .btn:active {
        transform: scale(0.98);
    }
    
    .card:active {
        transform: scale(0.99);
    }
    
    .nav-card:active {
        transform: scale(0.99);
    }
}

/* Print Styles */
@media print {
    
    body::before,
    body::after {
        display: none;
    }
    
    .navbar,
    .btn,
    .modal,
    .toast {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .table {
        border: 1px solid #000;
    }
    
    .table th,
    .table td {
        border: 1px solid #000;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    
    :root {
        --border-color: #000;
        --text-primary: #000;
        --text-secondary: #333;
    }
    
    .card,
    .btn,
    .table,
    input,
    select,
    textarea {
        border-width: 3px;
        border-color: #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .card:hover,
    .btn:hover,
    .nav-card:hover {
        transform: none;
    }
}

/* Dark Mode Support (Future Enhancement) */
@media (prefers-color-scheme: dark) {
    
    /* Uncomment when implementing dark mode */
    /*
    :root {
        --background-color: #1a1a2e;
        --card-background: #16213e;
        --text-primary: #eee;
        --text-secondary: #aaa;
        --border-color: #333;
    }
    
    body::before {
        background: linear-gradient(135deg, #1a1a2e, #16213e);
    }
    */
}

/* Specific Component Responsive Fixes */

/* Evaluation Form */
@media (max-width: 768px) {
    
    .rating-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .rating-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .rating-button {
        flex: 1;
        min-width: 44px;
    }
}

/* Teacher Dashboard */
@media (max-width: 768px) {
    
    .performance-chart {
        height: 250px !important;
    }
    
    .feedback-card {
        padding: 1rem;
    }
    
    .feedback-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Admin Pages */
@media (max-width: 768px) {
    
    .admin-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-tab {
        white-space: nowrap;
        min-width: auto;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .filter-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
    }
}

/* Principal Dashboard */
@media (max-width: 768px) {
    
    .performance-overview {
        grid-template-columns: 1fr !important;
    }
    
    .teacher-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .teacher-info {
        width: 100%;
    }
    
    .teacher-stats {
        width: 100%;
        justify-content: space-between;
    }
}

/* Reports Page */
@media (max-width: 768px) {
    
    .report-filters {
        flex-direction: column;
        gap: 1rem;
    }
    
    .report-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .report-actions .btn {
        width: 100%;
    }
    
    .chart-container {
        height: 250px !important;
        margin-bottom: 1.5rem;
    }
}

/* Strand Tabs */
@media (max-width: 768px) {
    
    .strand-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .strand-tab {
        white-space: nowrap;
        min-width: auto;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        border-width: 2px;
    }
}

/* Section Management */
@media (max-width: 768px) {
    
    .section-card {
        padding: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .section-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Student List */
@media (max-width: 768px) {
    
    .student-card {
        padding: 1rem;
    }
    
    .student-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .student-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .student-actions .btn {
        width: 100%;
    }
}

/* Accessibility Improvements */

/* Focus Visible */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip to Content Link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 9999;
}

.skip-to-content:focus {
    top: 0;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
