/* ========================================
   Mobile-First Responsive Styles
   ShiftsCover - Comprehensive Mobile Support
   ======================================== */

/* ----------------------------------------
   Base Mobile Adjustments
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Typography scaling */
    html {
        font-size: 14px;
    }
    
    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; }
    
    /* Container padding */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Cards */
    .card {
        border-radius: 8px;
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        padding: 0.625rem 1rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Tables - Make scrollable */
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack table cells on mobile */
    .table-stack-mobile tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        padding: 0.5rem;
    }
    
    .table-stack-mobile tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .table-stack-mobile tbody td:last-child {
        border-bottom: none;
    }
    
    .table-stack-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
    }
    
    .table-stack-mobile thead {
        display: none;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.625rem 0.75rem;
    }
    
    .form-label {
        font-size: 0.875rem;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* ----------------------------------------
   Tablet Adjustments (768px - 991px)
   ---------------------------------------- */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Two-column grids on tablet */
    .row-cols-tablet-2 > * {
        flex: 0 0 auto;
        width: 50%;
    }
}

/* ----------------------------------------
   Sidebar Mobile Behavior
   ---------------------------------------- */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        width: 280px;
        height: calc(100vh - 60px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-backdrop {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

/* ----------------------------------------
   Calendar Components
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Calendar grid */
    .calendar-grid {
        font-size: 0.75rem;
    }
    
    .calendar-day {
        min-height: 60px;
        padding: 0.25rem;
    }
    
    .calendar-day-number {
        font-size: 0.8rem;
    }
    
    /* Week view - horizontal scroll */
    .week-view-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .week-view-grid {
        min-width: 700px;
    }
    
    /* Day slots */
    .day-slot {
        min-height: 80px;
    }
}

/* ----------------------------------------
   Dashboard Components
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Stat cards */
    .stat-card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.75rem;
    }
    
    /* Quick action buttons */
    .quick-action-btn {
        padding: 1rem;
    }
    
    .quick-action-btn i {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .quick-action-btn span {
        font-size: 0.8rem;
    }
    
    /* Charts */
    .chart-container {
        height: 250px !important;
    }
}

/* ----------------------------------------
   Timesheet & Forms
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Time entry form */
    .time-entry-row {
        display: block;
        padding: 1rem;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        margin-bottom: 0.75rem;
    }
    
    .time-entry-row .form-group {
        margin-bottom: 0.75rem;
    }
    
    /* Inline form groups */
    .form-inline-mobile {
        display: block;
    }
    
    .form-inline-mobile > * {
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    /* Date range pickers */
    .date-range-picker {
        flex-direction: column;
    }
    
    .date-range-picker .separator {
        display: none;
    }
}

/* ----------------------------------------
   Shift Marketplace
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Shift cards */
    .shift-card {
        padding: 1rem;
    }
    
    .shift-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .shift-card-header .badge {
        margin-top: 0.5rem;
    }
    
    .shift-card-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .shift-card-actions .btn {
        width: 100%;
    }
}

/* ----------------------------------------
   Skill Matrix
   ---------------------------------------- */
@media (max-width: 767.98px) {
    .skill-matrix-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .skill-matrix {
        min-width: 600px;
    }
    
    .skill-matrix th,
    .skill-matrix td {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .skill-badge {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }
}

/* ----------------------------------------
   Template Builder
   ---------------------------------------- */
@media (max-width: 991.98px) {
    .builder-container {
        grid-template-columns: 1fr;
    }
    
    .toolbox {
        position: relative;
        top: 0;
        max-height: none;
        margin-bottom: 1rem;
    }
    
    .toolbox-section {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .shift-block {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 140px;
    }
}

@media (max-width: 575.98px) {
    .cycle-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .day-slot {
        min-height: 100px;
    }
    
    .preview-day {
        height: 24px;
        font-size: 0.6rem;
    }
}

/* ----------------------------------------
   Approval Queue
   ---------------------------------------- */
@media (max-width: 767.98px) {
    .approval-card {
        padding: 1rem;
    }
    
    .approval-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .approval-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .approval-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .approval-actions .btn {
        flex: 1;
    }
}

/* ----------------------------------------
   Reports
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Report filters */
    .report-filters {
        flex-direction: column;
    }
    
    .report-filters .form-group {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    /* Export buttons */
    .export-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .export-buttons .btn {
        flex: 1 1 auto;
    }
}

/* ----------------------------------------
   Navigation Helpers
   ---------------------------------------- */
@media (max-width: 767.98px) {
    /* Bottom navigation for key actions */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e9ecef;
        padding: 0.5rem;
        display: flex;
        justify-content: space-around;
        z-index: 1030;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
        color: #6b7280;
        text-decoration: none;
        font-size: 0.7rem;
    }
    
    .mobile-bottom-nav .nav-item.active {
        color: #4f46e5;
    }
    
    .mobile-bottom-nav .nav-item i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }
    
    /* Add padding to main content when bottom nav is present */
    .has-bottom-nav .main-content {
        padding-bottom: 70px;
    }
}

/* ----------------------------------------
   Touch-Friendly Adjustments
   ---------------------------------------- */
@media (max-width: 991.98px) {
    /* Larger touch targets */
    .btn,
    .nav-link,
    .dropdown-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Checkbox and radio */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Dropdown items */
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
    
    /* List items */
    .list-group-item {
        padding: 1rem;
    }
    
    /* Pagination */
    .page-link {
        padding: 0.625rem 0.875rem;
    }
}

/* ----------------------------------------
   Swipe Gestures Support (CSS only hints)
   ---------------------------------------- */
@media (max-width: 991.98px) {
    .swipeable-card {
        touch-action: pan-x;
        overflow: hidden;
    }
    
    .swipeable-card-content {
        transition: transform 0.3s ease;
    }
    
    .swipeable-card-actions {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        padding: 0 1rem;
        background: #ef4444;
        color: white;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
}

/* ----------------------------------------
   Print Styles (for reports)
   ---------------------------------------- */
@media print {
    .sidebar,
    .navbar-main,
    .mobile-bottom-nav,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .table {
        font-size: 10pt;
    }
}

/* ----------------------------------------
   Landscape Mode Adjustments
   ---------------------------------------- */
@media (max-width: 991.98px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
    
    .modal-dialog {
        max-height: 90vh;
    }
    
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ----------------------------------------
   Safe Area Insets (for notched devices)
   ---------------------------------------- */
@supports (padding: max(0px)) {
    .navbar-main {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    
    .mobile-bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-left: max(0px, env(safe-area-inset-left));
    }
}

/* ----------------------------------------
   Dark Mode Support (follows system)
   ---------------------------------------- */
@media (prefers-color-scheme: dark) {
    /* Optional: Enable if you want auto dark mode */
    /*
    :root {
        --bg-color: #1a1a2e;
        --card-bg: #16213e;
        --text-color: #e5e7eb;
        --border-color: #374151;
    }
    
    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }
    
    .card {
        background: var(--card-bg);
        border-color: var(--border-color);
    }
    */
}

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

