/* Mobile-First CSS for Flask Quote Management System */
/* Phase 1: Critical Display Fixes */

/* Mobile card styles */
.mobile-card-view {
    padding: 0 15px;
}

.mobile-card {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.mobile-card:active {
    transform: scale(0.98);
}

.mobile-card-header .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.detail-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #6c757d;
}

.detail-row i {
    width: 16px;
    text-align: center;
    color: #0d6efd;
}

.mobile-card-stats .stat-number {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
}

.mobile-card-stats .stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
}

.mobile-card-actions .btn {
    min-height: 44px; /* Touch target compliance */
    font-size: 0.9rem;
}

/* Ensure proper spacing for touch */
.mobile-card-actions .btn-group .btn {
    border-radius: 0;
}

.mobile-card-actions .btn-group .btn:first-child {
    border-radius: 6px 0 0 6px;
}

.mobile-card-actions .btn-group .btn:last-child {
    border-radius: 0 6px 6px 0;
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #dee2e6;
    z-index: 1000;
    /* Respect iOS safe area */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Spacer to prevent content being hidden behind fixed bottom nav */
.mobile-bottom-spacer {
    height: calc(64px + env(safe-area-inset-bottom));
}

.mobile-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    max-width: 100%;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #6c757d;
    font-size: 0.75rem;
    padding: 8px 12px;
    min-height: 44px; /* Touch target */
    min-width: 44px;
    border: none;
    background: none;
    transition: color 0.2s ease;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: #0d6efd;
}

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

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
}

.mobile-menu {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mobile-menu-overlay.show .mobile-menu {
    transform: translateY(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    color: #2c3e50;
    text-decoration: none;
    font-size: 1rem;
    border-bottom: 1px solid #f8f9fa;
    min-height: 44px;
}

.mobile-menu-item:hover {
    color: #0d6efd;
    background: #f8f9fa;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Mobile-optimized forms */
.mobile-optimized-form {
    padding: 0;
}

.form-control-mobile {
    min-height: 44px; /* Touch target compliance */
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px 16px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: border-color 0.2s ease;
}

.form-control-mobile:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-section {
    margin-bottom: 24px;
    padding: 20px 0;
}

.form-section-title {
    color: #0d6efd;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.btn-mobile {
    min-height: 44px; /* Touch target compliance */
    font-size: 1rem;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding: 20px 0;
}

.form-actions .btn-mobile {
    flex: 1;
}

/* Touch-optimized buttons */
.btn-touch {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-touch:active {
    transform: scale(0.98);
}

/* Action button groups with proper spacing */
.action-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-group .btn {
    flex: 1;
    min-width: 120px;
}

/* Status badges with better touch targets */
.status-badge-touch {
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 20px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

/* Quick action buttons */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.quick-action-btn {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
    white-space: nowrap;
}

/* Mobile dashboard stats */
.dashboard-stats {
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card-primary .stat-icon {
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
}

.stat-card-warning .stat-icon {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.stat-card-success .stat-icon {
    background: rgba(25, 135, 84, 0.1);
    color: #198754;
}

.stat-card-info .stat-icon {
    background: rgba(13, 202, 240, 0.1);
    color: #0dcaf0;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive typography system */
:root {
    /* Base font sizes */
    --font-size-xs: 0.75rem;   /* 12px */
    --font-size-sm: 0.875rem;  /* 14px */
    --font-size-base: 1rem;    /* 16px */
    --font-size-lg: 1.125rem;  /* 18px */
    --font-size-xl: 1.25rem;   /* 20px */
    --font-size-2xl: 1.5rem;   /* 24px */
    --font-size-3xl: 1.875rem; /* 30px */
    
    /* Line heights */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
}

/* Mobile-first typography */
body {
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
}

h1, .h1 {
    font-size: var(--font-size-2xl);
    line-height: var(--line-height-tight);
    font-weight: 700;
}

h2, .h2 {
    font-size: var(--font-size-xl);
    line-height: var(--line-height-tight);
    font-weight: 600;
}

h3, .h3 {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-tight);
    font-weight: 600;
}

h4, .h4, h5, .h5, h6, .h6 {
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    font-weight: 600;
}

/* Small text */
.text-sm {
    font-size: var(--font-size-sm);
}

.text-xs {
    font-size: var(--font-size-xs);
}

/* Improved readability */
.readable-text {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: #2c3e50;
}

.help-text {
    font-size: var(--font-size-sm);
    color: #6c757d;
    line-height: var(--line-height-normal);
}

/* Adjust main content for bottom nav */
@media (max-width: 992px) {
    .container {
        padding-bottom: 80px; /* Space for bottom nav */
    }
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
    }
    
    .modal-content {
        height: 100%;
        border: none;
        border-radius: 0;
    }
    
    .modal-body {
        padding: 20px 15px;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 15px 15px 10px;
        border-bottom: 1px solid #dee2e6;
    }
    
    .modal-footer {
        padding: 10px 15px 15px;
        border-top: 1px solid #dee2e6;
    }
}

/* Mobile adjustments */
@media (max-width: 576px) {
    .stat-card {
        padding: 16px;
        gap: 12px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .quick-action-btn {
        min-width: 100%;
        margin-bottom: 8px;
    }
}

/* Mobile table adjustments */
@media (max-width: 767px) {
    /* Hide Description column on mobile (for tables other than quotes) */
    #jobs .table th:nth-child(3),
    #jobs .table td:nth-child(3),
    #invoices .table th:nth-child(3),
    #invoices .table td:nth-child(3),
    #clients .table th:nth-child(3),
    #clients .table td:nth-child(3) {
        display: none;
    }
    
    /* Adjust table layout for mobile */
    .table-responsive {
        font-size: 0.875rem;
        /* Allow dropdowns to escape table bounds */
        overflow: visible;
    }
    
    /* Actions column - stack buttons vertically */
    .table-actions {
        position: relative;
        min-width: 120px;
        overflow: visible;
    }
    
    .table-actions .btn-view,
    .table-actions .mobile-actions-toggle {
        display: block;
        width: 80px;
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
        line-height: 1.5;
        text-align: center;
    }
    
    .table-actions .btn-view {
        margin-bottom: 0.5rem;
    }
    
    /* Make hamburger button the positioning context for dropdown */
    .table-actions .mobile-actions-toggle {
        position: relative;
    }
    
    /* Status badge wrapping for long text */
    .status-badge {
        max-width: 120px;
        word-wrap: break-word;
        line-height: 1.2;
        padding: 0.5rem 0.75rem;
        text-align: center;
        display: inline-block;
    }
    
    .status-badge[data-short="true"] {
        white-space: nowrap;
    }
    
    .status-badge:not([data-short]) {
        white-space: normal;
    }
    
    /* Ensure proper vertical alignment */
    .table td {
        vertical-align: middle;
    }
    
    /* Adjust client info display */
    .table td small {
        font-size: 0.75rem;
        line-height: 1.2;
    }
}

/* Mobile dropdown menu for actions */
.mobile-actions-dropdown {
    position: absolute;
    left: 0;
    top: 100%;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    min-width: 180px;
    display: none;
    overflow: hidden;
    margin-top: 4px;
}

.mobile-actions-dropdown.show {
    display: block;
}

.mobile-actions-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: #212529;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.mobile-actions-dropdown .dropdown-item:hover {
    background-color: #f8f9fa;
}

.mobile-actions-dropdown .dropdown-item i {
    margin-right: 8px;
    width: 16px;
}

.mobile-actions-dropdown .dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    border-top: 1px solid #dee2e6;
}

/* Tablet and desktop scaling */
@media (min-width: 768px) {
    :root {
        --font-size-xs: 0.8rem;
        --font-size-sm: 0.9rem;
        --font-size-base: 1rem;
        --font-size-lg: 1.2rem;
        --font-size-xl: 1.35rem;
        --font-size-2xl: 1.75rem;
        --font-size-3xl: 2.25rem;
    }
}

@media (min-width: 1200px) {
    :root {
        --font-size-xs: 0.875rem;
        --font-size-sm: 1rem;
        --font-size-base: 1.125rem;
        --font-size-lg: 1.25rem;
        --font-size-xl: 1.5rem;
        --font-size-2xl: 2rem;
        --font-size-3xl: 2.5rem;
    }
}
