/**
 * Mobile Optimization Styles for JIRA Clone
 * Responsive design for iPhone and Android devices
 */

/* ===== MOBILE BREAKPOINTS ===== */

/* Small phones (320px - 480px) */
@media (max-width: 480px) {

    /* Global adjustments */
    body {
        font-size: 14px;
    }

    /* Navbar */
    .navbar {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .navbar-logo {
        font-size: 1.2rem;
    }

    .navbar-left,
    .navbar-right {
        flex: 1;
    }

    .date-time {
        display: none;
        /* Hide on very small screens */
    }

    /* Navigation tabs */
    .nav-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Main content */
    .main-content {
        padding: 1rem;
        margin-top: 120px;
        /* Account for wrapped navbar */
    }

    /* View headers */
    .view-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }

    .view-header h2 {
        font-size: 1.5rem;
    }

    /* Buttons */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        width: 100%;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        margin: 0.25rem 0;
    }

    /* Cards */
    .card {
        margin-bottom: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Task cards */
    .task-card {
        padding: 1rem;
    }

    .task-card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .task-title {
        font-size: 1rem;
    }

    .task-card-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Project grid */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Timesheet Controls */
    .timesheet-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .timesheet-controls input,
    .timesheet-controls select {
        width: 100%;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        /* Prevent zoom on iOS */
        padding: 0.75rem;
    }

    /* Modals */
    .modal {
        padding: 1rem;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.5rem;
    }

    /* Dropdown menus */
    .dropdown-menu {
        position: fixed;
        top: auto !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto;
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Notifications dropdown */
    .notifications-dropdown {
        width: calc(100vw - 2rem);
        left: 1rem !important;
        right: 1rem !important;
    }

    /* User profile dropdown */
    .user-profile-dropdown {
        right: 1rem !important;
        left: auto !important;
        width: calc(100vw - 2rem);
    }

    /* Chat interface */
    .chat-container {
        height: calc(100vh - 200px);
    }

    .chat-messages {
        height: calc(100vh - 320px);
        padding: 0.75rem;
    }

    .chat-message {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .chat-input-container {
        padding: 0.75rem;
    }

    .chat-input {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Online users list */
    .online-users-list {
        max-height: 200px;
    }

    .online-user {
        padding: 0.75rem;
    }

    /* Toast notifications */
    .toast {
        left: 1rem;
        right: 1rem;
        width: auto;
        max-width: none;
    }

    /* Loading overlay */
    .loading-spinner {
        width: 50px;
        height: 50px;
    }
}

/* Medium phones and small tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {

    /* Navbar */
    .navbar {
        padding: 1rem 1.5rem;
    }

    /* Main content */
    .main-content {
        padding: 1.5rem;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Project grid */
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Task columns */
    .task-columns {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Forms */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Modals */
    .modal-content {
        width: 90%;
        max-width: 600px;
    }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Project grid */
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Task columns */
    .task-columns {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== TOUCH OPTIMIZATIONS ===== */

/* Larger touch targets */
@media (hover: none) and (pointer: coarse) {

    .btn,
    .tab-btn,
    .icon-btn,
    .dropdown-toggle,
    .task-card,
    .project-card {
        min-height: 44px;
        /* iOS recommended minimum */
        cursor: pointer;
    }

    /* Add tap highlight color */
    .btn,
    .tab-btn,
    .task-card,
    .project-card {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Improve scrolling */
    .task-columns,
    .chat-messages,
    .notifications-list,
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .task-card:hover,
    .project-card:hover {
        transform: none;
    }

    /* Add active state for better feedback */
    .btn:active,
    .tab-btn:active,
    .task-card:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* ===== LANDSCAPE ORIENTATION ===== */

@media (max-width: 768px) and (orientation: landscape) {

    /* Reduce navbar height */
    .navbar {
        padding: 0.5rem 1rem;
    }

    .navbar-logo {
        font-size: 1rem;
    }

    /* Adjust main content */
    .main-content {
        margin-top: 60px;
        padding: 1rem;
    }

    /* Optimize chat for landscape */
    .chat-messages {
        height: calc(100vh - 180px);
    }

    /* Reduce modal height */
    .modal-content {
        max-height: 85vh;
    }
}

/* ===== iOS SPECIFIC ===== */

/* Safe area insets for iPhone X and newer */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: env(safe-area-inset-top);
    }

    .main-content {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }

    .modal {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Fix iOS input zoom */
@media screen and (max-width: 768px) {

    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* ===== ANDROID SPECIFIC ===== */

/* Improve Material Design feel */
@media (max-width: 768px) {

    .card,
    .modal-content,
    .dropdown-menu {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .btn {
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-weight: 600;
    }
}

/* ===== ACCESSIBILITY ===== */

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .task-card,
    .project-card,
    .card {
        border: 2px solid var(--border-color);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== UTILITY CLASSES FOR MOBILE ===== */

/* Hide on mobile */
.hide-mobile {
    display: none !important;
}

@media (min-width: 769px) {
    .hide-mobile {
        display: block !important;
    }

    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* Fullwidth on mobile */
@media (max-width: 768px) {
    .mobile-fullwidth {
        width: 100% !important;
    }

    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-center {
        text-align: center !important;
        justify-content: center !important;
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Reduce animations on mobile */
@media (max-width: 768px) {

    .task-card,
    .project-card,
    .btn {
        transition: opacity 0.15s ease;
    }

    /* Use transform for better performance */
    .modal {
        transform: translateZ(0);
        will-change: transform;
    }
}

/* ===== PRINT STYLES ===== */

@media print {

    .navbar,
    .nav-tabs,
    .btn,
    .modal,
    .toast,
    .dropdown-menu {
        display: none !important;
    }

    .main-content {
        margin-top: 0;
        padding: 0;
    }

    .task-card,
    .project-card,
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}