/* AKEWE.COM - Perfect Mobile Responsiveness for Nigerian Users */
/* Optimized for all device sizes, touch interactions, and network conditions */

/* ===================================== */
/* BASE MOBILE RESET & FOUNDATIONS */
/* ===================================== */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    overflow-x: hidden;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent horizontal scroll */
.container, .wrapper, main, section {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ===================================== */
/* RESPONSIVE TYPOGRAPHY */
/* ===================================== */
@media (max-width: 640px) {
    h1 { font-size: clamp(1.5rem, 6vw, 2rem); }
    h2 { font-size: clamp(1.25rem, 5vw, 1.75rem); }
    h3 { font-size: clamp(1.1rem, 4vw, 1.5rem); }
    h4 { font-size: clamp(1rem, 3.5vw, 1.25rem); }
    p, .text-base { font-size: clamp(0.9rem, 3vw, 1rem); }
    .text-sm { font-size: clamp(0.8rem, 2.5vw, 0.875rem); }
    .text-xs { font-size: clamp(0.7rem, 2vw, 0.75rem); }
}

/* ===================================== */
/* MOBILE NAVIGATION OPTIMIZATION */
/* ===================================== */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border-top: 1px solid #e5e7eb;
    height: 56px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-decoration: none;
    color: #6b7280;
    font-size: 11px;
    transition: all 0.2s;
}

.mobile-bottom-nav .nav-item.active {
    color: #22c55e;
}

.mobile-bottom-nav .nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

/* Content spacing for fixed navigation */
@media (max-width: 768px) {
    main, .main-content {
        padding-top: 60px;
        padding-bottom: 60px;
    }
}

/* ===================================== */
/* TOUCH-OPTIMIZED COMPONENTS */
/* ===================================== */
.touch-button {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.touch-button:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* Touch-friendly form elements */
input, textarea, select {
    min-height: 44px;
    padding: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 8px;
    width: 100%;
    border: 1px solid #d1d5db;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* ===================================== */
/* MOBILE CARDS & LISTS */
/* ===================================== */
@media (max-width: 640px) {
    .card, .post-card {
        border-radius: 0;
        margin-left: -16px;
        margin-right: -16px;
        padding: 16px;
        border-left: none;
        border-right: none;
    }
    
    .card + .card {
        margin-top: 8px;
    }
    
    .list-item {
        padding: 16px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .list-item:last-child {
        border-bottom: none;
    }
}

/* ===================================== */
/* MOBILE MODALS & SHEETS */
/* ===================================== */
@media (max-width: 640px) {
    .modal, .dialog {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        animation: slideUp 0.3s ease;
    }
    
    .modal-content {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        border-bottom: 1px solid #e5e7eb;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
    }
    
    .modal-close {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #f3f4f6;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ===================================== */
/* MOBILE IMAGES & MEDIA */
/* ===================================== */
img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

.media-container {
    position: relative;
    width: 100%;
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
}

/* Responsive image gallery */
@media (max-width: 640px) {
    .image-gallery {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }
    
    .image-gallery-item {
        aspect-ratio: 1;
        overflow: hidden;
    }
    
    .image-gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* ===================================== */
/* MOBILE FEED & TIMELINE */
/* ===================================== */
@media (max-width: 640px) {
    .feed-container {
        padding: 0;
    }
    
    .post {
        margin-bottom: 8px;
        background: white;
        border-top: 1px solid #e5e7eb;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .post-header {
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }
    
    .post-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-right: 12px;
    }
    
    .post-content {
        padding: 0 16px 12px;
    }
    
    .post-media {
        margin: 0 -16px;
        width: calc(100% + 32px);
    }
    
    .post-actions {
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
        border-top: 1px solid #e5e7eb;
    }
    
    .post-action {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
        color: #6b7280;
    }
}

/* ===================================== */
/* MOBILE CHAT INTERFACE */
/* ===================================== */
@media (max-width: 640px) {
    .chat-container {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .chat-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: white;
        padding: 12px 16px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 60px 16px 80px;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        display: flex;
        gap: 8px;
    }
    
    .chat-input {
        flex: 1;
        min-height: 40px;
        padding: 10px 12px;
        border-radius: 20px;
        border: 1px solid #d1d5db;
        font-size: 16px;
    }
}

/* ===================================== */
/* MOBILE PROFILE PAGE */
/* ===================================== */
@media (max-width: 640px) {
    .profile-header {
        padding: 16px;
        background: white;
    }
    
    .profile-cover {
        height: 120px;
        margin: -16px -16px 16px;
        background: linear-gradient(135deg, #22c55e, #16a34a);
    }
    
    .profile-avatar-large {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 4px solid white;
        margin-top: -40px;
        position: relative;
    }
    
    .profile-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 16px 0;
        text-align: center;
    }
    
    .profile-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid #e5e7eb;
        padding: 0 16px;
    }
    
    .profile-tab {
        padding: 12px 16px;
        white-space: nowrap;
        border-bottom: 2px solid transparent;
        color: #6b7280;
    }
    
    .profile-tab.active {
        color: #22c55e;
        border-bottom-color: #22c55e;
    }
}

/* ===================================== */
/* MOBILE SEARCH & DISCOVERY */
/* ===================================== */
@media (max-width: 640px) {
    .search-container {
        padding: 16px;
        position: sticky;
        top: 0;
        background: white;
        z-index: 100;
    }
    
    .search-input-wrapper {
        position: relative;
    }
    
    .search-input {
        width: 100%;
        padding: 12px 16px 12px 44px;
        border-radius: 24px;
        background: #f3f4f6;
        border: none;
        font-size: 16px;
    }
    
    .search-icon {
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
    }
    
    .search-results {
        padding: 16px;
    }
    
    .search-filter-chips {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
    }
    
    .filter-chip {
        padding: 8px 16px;
        border-radius: 20px;
        background: #f3f4f6;
        white-space: nowrap;
        font-size: 14px;
    }
    
    .filter-chip.active {
        background: #22c55e;
        color: white;
    }
}

/* ===================================== */
/* MOBILE STORIES */
/* ===================================== */
@media (max-width: 640px) {
    .stories-container {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
        background: white;
    }
    
    .story-item {
        flex: 0 0 80px;
        text-align: center;
    }
    
    .story-avatar {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        border: 3px solid #22c55e;
        padding: 2px;
        background: white;
        margin-bottom: 4px;
    }
    
    .story-avatar img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        object-fit: cover;
    }
    
    .story-username {
        font-size: 11px;
        color: #4b5563;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ===================================== */
/* MOBILE NOTIFICATIONS */
/* ===================================== */
@media (max-width: 640px) {
    .notification-item {
        display: flex;
        padding: 16px;
        border-bottom: 1px solid #e5e7eb;
        background: white;
    }
    
    .notification-item.unread {
        background: #f0fdf4;
    }
    
    .notification-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-right: 12px;
        flex-shrink: 0;
    }
    
    .notification-content {
        flex: 1;
        min-width: 0;
    }
    
    .notification-text {
        font-size: 14px;
        line-height: 1.5;
        margin-bottom: 4px;
    }
    
    .notification-time {
        font-size: 12px;
        color: #9ca3af;
    }
}

/* ===================================== */
/* MOBILE FORMS & INPUTS */
/* ===================================== */
@media (max-width: 640px) {
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-label {
        display: block;
        margin-bottom: 6px;
        font-size: 14px;
        font-weight: 500;
        color: #374151;
    }
    
    .form-input {
        width: 100%;
        padding: 12px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 16px;
        transition: border-color 0.2s;
    }
    
    .form-input:focus {
        outline: none;
        border-color: #22c55e;
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
    }
    
    .form-submit {
        width: 100%;
        padding: 14px;
        background: #22c55e;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
    }
    
    .form-submit:active {
        background: #16a34a;
    }
}

/* ===================================== */
/* MOBILE ACTION SHEETS */
/* ===================================== */
@media (max-width: 640px) {
    .action-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 16px 16px 0 0;
        padding: 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 2000;
    }
    
    .action-sheet.active {
        transform: translateY(0);
    }
    
    .action-sheet-handle {
        width: 40px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
        margin: 8px auto 16px;
    }
    
    .action-sheet-item {
        display: flex;
        align-items: center;
        padding: 16px;
        border-radius: 8px;
        color: #111827;
        text-decoration: none;
    }
    
    .action-sheet-item:active {
        background: #f3f4f6;
    }
    
    .action-sheet-item i {
        width: 24px;
        margin-right: 12px;
        color: #6b7280;
    }
}

/* ===================================== */
/* MOBILE LOADING STATES */
/* ===================================== */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 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; }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================================== */
/* PULL TO REFRESH */
/* ===================================== */
.pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.pull-to-refresh.active {
    transform: translateY(60px);
}

/* ===================================== */
/* MOBILE TABLES */
/* ===================================== */
@media (max-width: 640px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    .responsive-table {
        display: block;
    }
    
    .responsive-table thead {
        display: none;
    }
    
    .responsive-table tbody {
        display: block;
    }
    
    .responsive-table tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
    }
    
    .responsive-table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border: none;
    }
    
    .responsive-table td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 8px;
        color: #6b7280;
    }
}

/* ===================================== */
/* FLOATING ACTION BUTTON */
/* ===================================== */
.fab {
    position: fixed;
    bottom: 76px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #22c55e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    z-index: 999;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

.fab i {
    font-size: 24px;
}

/* ===================================== */
/* TABLET OPTIMIZATIONS */
/* ===================================== */
@media (min-width: 641px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 24px;
    }
    
    .grid-responsive {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 24px;
    }
    
    .sidebar-mobile {
        display: none;
    }
    
    .main-content-tablet {
        margin-left: 240px;
    }
}

/* ===================================== */
/* LANDSCAPE MOBILE ADJUSTMENTS */
/* ===================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-header {
        height: 48px;
    }
    
    .mobile-bottom-nav {
        height: 48px;
    }
    
    .modal {
        max-height: 80vh;
    }
    
    .chat-messages {
        padding: 52px 16px 52px;
    }
}

/* ===================================== */
/* NIGERIAN NETWORK OPTIMIZATIONS */
/* ===================================== */
/* Low bandwidth mode */
@media (prefers-reduced-data: reduce) {
    img, video {
        opacity: 0.8;
        filter: blur(5px);
    }
    
    img.loaded, video.loaded {
        opacity: 1;
        filter: none;
        transition: opacity 0.3s, filter 0.3s;
    }
    
    .high-res-image {
        display: none;
    }
    
    .low-res-placeholder {
        display: block;
    }
}

/* ===================================== */
/* ACCESSIBILITY ENHANCEMENTS */
/* ===================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for keyboard navigation */
*:focus-visible {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

/* ===================================== */
/* PRINT STYLES */
/* ===================================== */
@media print {
    .mobile-header,
    .mobile-bottom-nav,
    .sidebar,
    .fab,
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a {
        text-decoration: underline;
    }
    
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
}

/* ===================================== */
/* PROGRESSIVE WEB APP STYLES */
/* ===================================== */
@media (display-mode: standalone) {
    .mobile-header {
        padding-top: env(safe-area-inset-top);
        height: calc(56px + env(safe-area-inset-top));
    }
    
    .install-prompt {
        display: none;
    }
}

/* ===================================== */
/* DARK MODE MOBILE OPTIMIZATIONS */
/* ===================================== */
@media (prefers-color-scheme: dark) {
    body {
        background: #111827;
        color: #f9fafb;
    }
    
    .mobile-header,
    .mobile-bottom-nav {
        background: #1f2937;
        border-color: #374151;
    }
    
    .card, .post {
        background: #1f2937;
        border-color: #374151;
    }
    
    input, textarea, select {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .modal {
        background: #1f2937;
    }
    
    .notification-item.unread {
        background: #064e3b;
    }
}

/* ===================================== */
/* CUSTOM SCROLLBAR FOR MOBILE */
/* ===================================== */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #22c55e;
    border-radius: 2px;
}

/* ===================================== */
/* PERFORMANCE OPTIMIZATIONS */
/* ===================================== */
.hardware-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

.optimize-legibility {
    text-rendering: optimizeLegibility;
}

/* Reduce animations for battery saving */
@media (prefers-reduced-motion: no-preference) {
    .smooth-transition {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}