/**
 * Mobile-Responsive CSS for Lecture Remuneration Tracker
 * Comprehensive mobile-first responsive design
 */

/* Base Mobile-First Styles */
* {
    box-sizing: border-box;
}

/* Typography Improvements */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.1rem; }
    h5, .h5 { font-size: 1rem; }
    h6, .h6 { font-size: 0.9rem; }
}

/* Header and Navigation */
@media (max-width: 768px) {
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }
    
    .d-flex.justify-content-between.align-items-center .btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .page-header h1 {
        text-align: center;
        margin-bottom: 1rem;
    }
}

/* Cards and Summary Statistics */
@media (max-width: 768px) {
    .summary-cards .card {
        margin-bottom: 1rem;
    }
    
    .summary-cards .card-body {
        padding: 1rem 0.75rem;
        text-align: center;
    }
    
    .summary-cards h4, .summary-cards h5 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .summary-cards small {
        font-size: 0.8rem;
        display: block;
    }
}

/* Form Controls */
@media (max-width: 768px) {
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
    }
    
    .form-text {
        font-size: 0.8rem;
        margin-top: 0.25rem;
    }
}

/* Buttons */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        border-radius: 0.5rem;
    }
    
    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .btn-block-mobile {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Tables - Mobile Card View */
@media (max-width: 991px) {
    .table-mobile-cards {
        display: none;
    }
    
    .mobile-card-view {
        display: block;
    }
    
    .mobile-card {
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #e9ecef;
    }
    
    .mobile-card-title {
        font-weight: 600;
        font-size: 1rem;
        margin-bottom: 0.25rem;
        color: #495057;
    }
    
    .mobile-card-subtitle {
        font-size: 0.9rem;
        color: #6c757d;
        margin-bottom: 0.25rem;
    }
    
    .mobile-card-meta {
        font-size: 0.8rem;
        color: #6c757d;
    }
    
    .mobile-card-amount {
        text-align: right;
        flex-shrink: 0;
    }
    
    .mobile-card-body {
        margin-bottom: 0.75rem;
    }
    
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }
    
    .mobile-card-label {
        font-weight: 500;
        color: #6c757d;
        font-size: 0.8rem;
    }
    
    .mobile-card-value {
        font-weight: 600;
        color: #495057;
    }
    
    .mobile-card-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #e9ecef;
    }
    
    .mobile-card-actions .btn {
        flex: 1;
    }
}

@media (min-width: 992px) {
    .table-mobile-cards {
        display: table;
    }
    
    .mobile-card-view {
        display: none;
    }
}

/* Modals */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .modal-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    .btn-close {
        padding: 1rem;
        margin: -1rem -1rem -1rem auto;
    }
}

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

/* Search and Filter Forms */
@media (max-width: 768px) {
    .search-filters .row > div {
        margin-bottom: 1rem;
    }
    
    .search-filters .btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .filter-section {
        background: #f8f9fa;
        padding: 1rem;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }
}

/* Alerts and Messages */
@media (max-width: 768px) {
    .alert {
        margin-bottom: 1rem;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .alert .btn {
        margin-top: 0.5rem;
        width: 100%;
    }
}

/* Badges and Labels */
@media (max-width: 768px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.35em 0.65em;
    }
    
    .badge-lg {
        font-size: 0.9rem;
        padding: 0.5em 0.75em;
    }
}

/* Pagination */
@media (max-width: 768px) {
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* Utility Classes */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-visible {
        display: block !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-mb-3 {
        margin-bottom: 1rem !important;
    }
    
    .mobile-p-2 {
        padding: 0.5rem !important;
    }
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .mobile-card {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .mobile-card-title {
        color: #e2e8f0;
    }
    
    .mobile-card-subtitle,
    .mobile-card-meta,
    .mobile-card-label {
        color: #a0aec0;
    }
}

/* Print Styles */
@media print {
    .mobile-card-view {
        display: none;
    }
    
    .table-mobile-cards {
        display: table !important;
    }
    
    .btn, .modal, .alert {
        display: none !important;
    }
}

/* Accessibility Improvements */
@media (max-width: 768px) {
    .sr-only-mobile {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    
    .focus-visible {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }
}

/* Animation and Transitions */
.mobile-card, .btn, .form-control, .form-select {
    transition: all 0.2s ease-in-out;
}

.mobile-card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Custom Scrollbar for Mobile */
@media (max-width: 768px) {
    .table-responsive {
        scrollbar-width: thin;
        scrollbar-color: #007bff #f1f1f1;
    }
    
    .table-responsive::-webkit-scrollbar {
        height: 6px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #007bff;
        border-radius: 3px;
    }
}

/* Enhanced Mobile Navigation */
@media (max-width: 768px) {
    /* Compact mobile navigation */
    .mobile-nav-compact {
        position: sticky;
        top: 76px;
        z-index: 999;
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        border-radius: 0 0 1rem 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .mobile-nav-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        color: white;
        cursor: pointer;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: none;
        border: none;
        width: 100%;
        text-align: left;
    }
    
    .mobile-nav-toggle:hover {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .mobile-nav-toggle i {
        transition: transform 0.3s ease;
        font-size: 1rem;
    }
    
    .mobile-nav-toggle.collapsed i {
        transform: rotate(180deg);
    }
    
    .mobile-nav-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .mobile-nav-content.show {
        max-height: 300px;
    }
    
    .mobile-nav-grid-compact {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .mobile-nav-item-compact {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 0.5rem;
        padding: 0.5rem;
        text-align: center;
        transition: all 0.2s ease;
        text-decoration: none;
        color: rgba(255, 255, 255, 0.9);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        min-height: 60px;
        justify-content: center;
    }
    
    .mobile-nav-item-compact:hover {
        background: rgba(255, 255, 255, 0.2);
        color: white;
        text-decoration: none;
        transform: scale(1.05);
    }
    
    .mobile-nav-item-compact.active {
        background: rgba(59, 130, 246, 0.4);
        color: white;
    }
    
    .mobile-nav-item-compact i {
        font-size: 1.1rem;
    }
    
    .mobile-nav-item-compact span {
        font-size: 0.7rem;
        font-weight: 500;
        line-height: 1;
    }
    
    /* Hide original mobile nav grid on mobile, use compact version */
    .mobile-nav-grid {
        display: none;
    }
    
    /* Ensure main content uses full width on mobile */
    .main-content {
        padding: 0.75rem !important;
    }
    
    /* Improve page headers on mobile */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
        margin-bottom: 1rem !important;
    }
    
    .d-flex.justify-content-between.align-items-center h1 {
        text-align: center;
        margin-bottom: 0.5rem;
        font-size: 1.5rem;
    }
    
    .d-flex.justify-content-between.align-items-center .btn {
        width: 100%;
        margin-top: 0;
    }
}
