/**
 * Mobile-First Responsive CSS for ezeTree
 * Optimized for mobile devices (phones and tablets)
 */

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Typography - Better readability on mobile */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 24px !important;
        line-height: 1.3;
        word-break: break-word;
        hyphens: auto;
    }
    
    h2 {
        font-size: 20px !important;
        line-height: 1.4;
    }
    
    h3 {
        font-size: 18px !important;
    }
    
    /* Container adjustments */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Card layouts */
    .card {
        margin-bottom: 15px;
        border-radius: 10px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Person View - Profile Section */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-image {
        max-width: 100% !important;
        height: auto !important;
        margin-bottom: 15px;
        float: none !important;
        margin-right: 0 !important;
    }
    
    /* Fix image wrapping on mobile */
    .img-fluid.float-start {
        float: none !important;
        display: block;
        margin: 0 auto 20px auto;
        max-width: 100%;
    }
    
    /* Person name - prevent awkward breaking */
    .person-name,
    h2.mb-1 {
        word-break: normal !important;
        overflow-wrap: break-word !important;
        hyphens: none !important;
        white-space: normal !important;
    }
    
    /* Badges */
    .badge {
        font-size: 12px;
        padding: 5px 10px;
        display: inline-block;
        margin: 5px 2px;
    }
    
    .badge-living,
    .badge-deceased {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    /* Sidebar on mobile */
    .sidebar {
        margin-top: 20px;
    }
    
    /* Quick Actions - Stack vertically on mobile */
    .quick-actions .btn,
    .btn-group-vertical .btn {
        width: 100%;
        margin-bottom: 10px;
        padding: 12px;
        font-size: 16px;
    }
    
    /* Tables - Make responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 14px;
    }
    
    table th,
    table td {
        padding: 8px;
        white-space: nowrap;
    }
    
    /* Forms - Better touch targets */
    .form-control,
    .form-select,
    select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px;
        height: auto;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* iOS touch target size */
    }
    
    .btn-sm {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }
    
    /* Navigation improvements */
    .navbar {
        padding: 10px;
    }
    
    .navbar-brand {
        font-size: 20px;
    }
    
    .navbar-toggler {
        padding: 8px 12px;
        font-size: 18px;
    }
    
    .nav-link {
        padding: 12px 15px;
        font-size: 16px;
    }
    
    /* Modal improvements */
    .modal-dialog {
        margin: 10px;
    }
    
    .modal-content {
        border-radius: 15px;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
    
    /* Tabs on mobile */
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tabs .nav-link {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    /* Biography section */
    .biography-section {
        text-align: justify;
        font-size: 15px;
        line-height: 1.7;
    }
    
    /* Family tree cards */
    .family-card {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .family-card .card-title {
        font-size: 16px;
    }
    
    /* Media gallery on mobile */
    .media-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .media-thumbnail {
        height: 150px;
    }
    
    /* Search forms */
    .search-box {
        margin-bottom: 15px;
    }
    
    .search-box input {
        font-size: 16px;
        padding: 12px;
    }
    
    /* DataTables on mobile */
    .dataTables_wrapper {
        font-size: 14px;
    }
    
    .dataTables_filter input {
        font-size: 16px !important;
    }
    
    /* Alert messages */
    .alert {
        padding: 12px;
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    /* Breadcrumbs */
    .breadcrumb {
        font-size: 14px;
        padding: 10px;
        flex-wrap: wrap;
    }
    
    /* Dashboard cards */
    .dashboard-card {
        margin-bottom: 15px;
    }
    
    .stat-box {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .stat-number {
        font-size: 32px;
    }
    
    /* Footer adjustments */
    .footer {
        padding: 20px 15px;
        font-size: 14px;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        font-size: 15px;
        min-width: auto;
    }
    
    .dropdown-item {
        padding: 12px 20px;
    }
    
    /* List groups */
    .list-group-item {
        padding: 12px 15px;
        font-size: 15px;
    }
    
    /* Spacing utilities - reduce on mobile */
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-4 {
        margin-top: 1.5rem !important;
    }
    
    .py-4 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    /* Hide elements on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 576px) {
    h1 {
        font-size: 22px !important;
    }
    
    h2 {
        font-size: 18px !important;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
    }
    
    /* Single column layout for very small screens */
    .row > [class*='col-'] {
        width: 100%;
    }
    
    /* Media gallery - single column */
    .media-gallery {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet adjustments */
@media (min-width: 577px) and (max-width: 768px) {
    .media-gallery {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    a, button {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover {
        transform: none;
    }
    
    /* Better tap highlight */
    a, button, input, select, textarea {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
    }
}

/* Landscape mode optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .profile-image {
        max-width: 40% !important;
        float: left !important;
        margin-right: 20px !important;
    }
    
    .modal-dialog {
        max-width: 90%;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS input zoom fix */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* iOS safe area (notch) */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .navbar {
        padding-top: max(10px, env(safe-area-inset-top));
    }
}

/* Force light mode for better contrast */
@media (max-width: 768px) {
    body {
        background-color: #f8f9fa !important;
        color: #212529 !important;
    }
    
    .card {
        background-color: #ffffff !important;
        border-color: #dee2e6 !important;
        color: #212529 !important;
    }
    
    .card-body {
        background-color: #ffffff !important;
        color: #212529 !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #212529 !important;
    }
    
    p, span, div {
        color: #212529 !important;
    }
    
    .text-muted {
        color: #6c757d !important;
    }
}

/* Accessibility - larger text option */
@media (max-width: 768px) {
    .large-text {
        font-size: 18px !important;
    }
    
    .large-text h1 {
        font-size: 28px !important;
    }
    
    .large-text h2 {
        font-size: 24px !important;
    }
}

/* Print styles for mobile */
@media print and (max-width: 768px) {
    .btn,
    .navbar,
    .sidebar,
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

