/* ============================================
   MOBİL OPTİMİZASYONLARI - TEVKIL PLATFORM
   ============================================ */

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }

    /* Fix container widths */
    * {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* Ensure all containers respect viewport */
    .container, .layout-content-container, [class*="col-"], .grid {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Touch-friendly targets (minimum 44x44px) */
    button, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better text readability on mobile */
    body {
        font-size: 16px;
        line-height: 1.6;
        -webkit-text-size-adjust: 100%;
    }

    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Remove tap highlight on iOS */
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ============================================
   HAMBURGER MENU (Mobile Navigation)
   ============================================ */
   
/* Floating Mobile Menu Button - Sağ kenarda */
#mobileMenuBtn {
    animation: pulse-subtle 3s ease-in-out infinite;
}

@keyframes pulse-subtle {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
    }
}

/* Buton hover efekti */
#mobileMenuBtn:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Buton active efekti */
#mobileMenuBtn:active {
    transform: translateY(-50%) scale(0.95);
}

.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    position: relative;
    cursor: pointer;
    background: transparent;
    border: none;
    z-index: 1000;
}

.mobile-menu-toggle span {
    display: block;
    width: 28px;
    height: 3px;
    background-color: currentColor;
    margin: 0 auto 5px;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle span:last-child {
    margin-bottom: 0;
}

/* Hamburger animation when open */
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile navigation overlay */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
    opacity: 1;
}

/* Mobile navigation menu */
.mobile-nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 999;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.mobile-nav-menu.active {
    right: 0;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-nav-overlay.active,
    .mobile-nav-menu {
        display: block;
    }

    /* Hide desktop menu on mobile */
    .desktop-nav {
        display: none !important;
    }
}

/* ============================================
   FORM OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Better form inputs on mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px 16px;
        border-radius: 8px;
    }

    /* Full width buttons on mobile */
    .btn, button[type="submit"] {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
        border-radius: 8px;
    }

    /* Stack form groups vertically */
    .form-group {
        margin-bottom: 16px;
    }

    /* Better select dropdowns */
    select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px;
    }
}

/* ============================================
   CARD OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Better card spacing on mobile */
    .card {
        margin-bottom: 16px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Reduce padding on small screens */
    .card-body {
        padding: 16px;
    }

    /* Stack card elements vertically */
    .card-header,
    .card-footer {
        padding: 12px 16px;
    }

    /* Better card images */
    .card-img-top {
        border-radius: 12px 12px 0 0;
        object-fit: cover;
        max-height: 200px;
    }
}

/* ============================================
   TABLE OPTIMIZATIONS (Responsive Tables)
   ============================================ */
@media (max-width: 768px) {
    /* Convert table to card layout on mobile */
    .responsive-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .responsive-table table {
        min-width: 100%;
        border: 0;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table tr {
        margin-bottom: 16px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
        background: white;
    }

    .responsive-table td {
        text-align: left;
        padding: 8px 0;
        border: none;
        position: relative;
        padding-left: 50%;
    }

    .responsive-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        font-weight: bold;
        color: #6b7280;
    }
}

/* ============================================
   MODAL OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .modal-header {
        padding: 16px;
        border-bottom: 1px solid #e5e7eb;
    }

    .modal-body {
        padding: 20px 16px;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 16px;
        border-top: 1px solid #e5e7eb;
    }
}

/* ============================================
   CHAT OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Hide conversation list when chat is open */
    .chat-container.conversation-open .conversation-list {
        display: none;
    }

    /* Full width chat messages */
    .chat-container.conversation-open .chat-panel {
        width: 100%;
    }

    /* Better message bubbles */
    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
        border-radius: 18px;
        font-size: 15px;
        line-height: 1.4;
    }

    /* Input area */
    .chat-input-area {
        padding: 8px 12px;
    }

    .chat-input {
        font-size: 16px;
        padding: 10px 14px;
    }
}

/* ============================================
   HEADER / NAVBAR OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Sticky mobile header */
    header {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 12px 16px;
    }

    /* Compact logo */
    .logo {
        height: 36px;
        width: auto;
    }

    /* Hide long text, show icons only */
    .nav-item-text {
        display: none;
    }

    .nav-item-icon {
        display: block;
    }
}

/* ============================================
   FOOTER OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    footer {
        padding: 24px 16px;
    }

    .footer-links {
        flex-direction: column;
        gap: 12px;
    }

    .footer-link {
        display: block;
        padding: 8px 0;
        text-align: center;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-card {
    height: 120px;
    margin-bottom: 16px;
}

/* ============================================
   TOUCH FEEDBACK
   ============================================ */
@media (hover: none) {
    /* Better touch feedback on mobile */
    button:active,
    a:active,
    .clickable:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    /* Remove hover effects on touch devices */
    button:hover,
    a:hover {
        transform: none;
    }
}

/* ============================================
   SAFE AREA (iPhone Notch)
   ============================================ */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .safe-area-bottom {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .safe-area-left {
        padding-left: max(16px, env(safe-area-inset-left));
    }

    .safe-area-right {
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* ============================================
   PULL TO REFRESH (Native Feel)
   ============================================ */
.pull-to-refresh {
    position: relative;
}

.pull-to-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.3s ease;
}

.pull-to-refresh.pulling .pull-to-refresh-indicator {
    top: 10px;
}

/* ============================================
   BOTTOM NAVIGATION (Mobile App Style)
   ============================================ */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        z-index: 100;
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 0;
        text-decoration: none;
        color: #6b7280;
        font-size: 12px;
        transition: all 0.2s ease;
        position: relative;
    }

    .bottom-nav-item.active {
        color: #2563eb;
    }

    .bottom-nav-item .material-symbols-outlined {
        font-size: 24px;
        margin-bottom: 4px;
    }

    .bottom-nav-item .badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 20px);
        background: #ef4444;
        color: white;
        border-radius: 10px;
        padding: 2px 6px;
        font-size: 10px;
        font-weight: bold;
        min-width: 18px;
        text-align: center;
    }

    /* Add bottom padding to main content to avoid bottom nav overlap */
    main, .main-content, #content, .layout-content-container {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }

    /* Specific dashboard fixes */
    .dashboard-content {
        padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important;
    }
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */
.offline-indicator {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fbbf24;
    color: #78350f;
    padding: 8px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.offline-indicator.show {
    display: block;
}

/* ============================================
   DARK MODE OPTIMIZATIONS
   ============================================ */
@media (prefers-color-scheme: dark) {
    .mobile-nav-menu {
        background: #1f2937;
        color: white;
    }

    .bottom-nav {
        background: #1f2937;
        border-top-color: #374151;
    }

    .skeleton {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
        background-size: 200% 100%;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media (max-width: 768px) {
    /* Better focus indicators for keyboard navigation */
    *:focus {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
    }

    /* Skip to main content link */
    .skip-to-main {
        position: absolute;
        top: -40px;
        left: 0;
        background: #2563eb;
        color: white;
        padding: 8px 16px;
        text-decoration: none;
        z-index: 100;
    }

    .skip-to-main:focus {
        top: 0;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
/* Enable hardware acceleration for smoother animations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
