/**
 * Mobile-First Core Styles
 * Base styles for 320px+ (smartphones)
 * Progressive enhancement for larger screens
 */

/* ========================================
   BASE MOBILE STYLES (320px+)
   ======================================== */

/* Reset and normalize for mobile */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
}

html {
    font-size: 16px; /* Base font size for mobile readability */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.8; /* Increased for mobile readability */
    font-size: 1rem;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ========================================
   MOBILE TYPOGRAPHY
   ======================================== */

h1 {
    font-size: 1.75rem;
    line-height: 1.3;
    margin: 1rem 0;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
    line-height: 1.4;
    margin: 0.875rem 0;
    font-weight: 600;
}

h3 {
    font-size: 1.25rem;
    line-height: 1.4;
    margin: 0.75rem 0;
    font-weight: 600;
}

h4 {
    font-size: 1.125rem;
    line-height: 1.5;
    margin: 0.625rem 0;
    font-weight: 600;
}

p {
    font-size: 1rem;
    line-height: 1.8;
    margin: 0.75rem 0;
}

/* ========================================
   MOBILE LAYOUT
   ======================================== */

.container {
    width: 100%;
    max-width: 100%;
    padding: 0 16px; /* Mobile padding */
    margin: 0 auto;
}

/* Mobile-friendly grid */
.mobile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
}

/* ========================================
   MOBILE NAVIGATION
   ======================================== */

.nav-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 12px 8px;
}

.nav-btn {
    min-width: 44px;
    min-height: 44px; /* Minimum touch target */
    padding: 12px 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.nav-btn:active {
    transform: scale(0.95);
}

/* ========================================
   MOBILE SEARCH INTERFACE
   ======================================== */

.search-container {
    width: 100%;
    padding: 16px;
    box-sizing: border-box;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

#searchInput,
#resolutionSearchInput,
#llaSearchInput {
    width: 100%;
    height: 48px; /* Large touch target */
    padding: 12px 48px 12px 16px;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    box-sizing: border-box;
}

#searchInput:focus,
#resolutionSearchInput:focus,
#llaSearchInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
    min-width: 48px;
    min-height: 48px;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 8px;
    margin-top: 12px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ========================================
   MOBILE FILTER INTERFACE
   ======================================== */

.filter-container {
    width: 100%;
    margin: 16px 0;
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 6px;
    color: #333;
}

.filter-select,
select {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    background: white;
    box-sizing: border-box;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.filter-select:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Active filter indicator */
.filter-active {
    border-color: #667eea !important;
    background-color: #f0f4ff !important;
}

/* Filter active badge */
.filter-active-badge {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 8px 0;
    text-align: center;
}

/* ========================================
   MOBILE PERIOD FILTERS
   ======================================== */

.period-filter-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.period-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.period-filter-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #333;
}

#year-start-filter,
#year-end-filter,
#subject-filter {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    background: white;
}

/* ========================================
   MOBILE DOCUMENT CARDS
   ======================================== */

.ordinance-card,
.resolution-card,
.document-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.document-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
    text-align: center;
    width: 100%;
}

.document-number {
    font-size: 0.875rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
    display: block;
    text-align: center;
    width: 100%;
}

.document-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 8px;
    color: #333;
    display: block;
    text-align: center;
    width: 100%;
}

.document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 12px;
    justify-content: center;
    width: 100%;
}

.document-excerpt {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: #555;
    margin-bottom: 16px;
    text-align: center;
    width: 100%;
}

/* ========================================
   MOBILE ACTION BUTTONS
   ======================================== */

.document-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.action-btn,
.view-btn,
.pdf-btn {
    width: 100%;
    min-height: 48px; /* Large touch target */
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    box-sizing: border-box;
}

.action-btn:active,
.view-btn:active,
.pdf-btn:active {
    transform: scale(0.97);
}

.view-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.pdf-btn {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

/* Button row for side-by-side on larger phones */
@media (min-width: 375px) {
    .document-actions {
        flex-direction: row;
    }

    .action-btn,
    .view-btn,
    .pdf-btn {
        flex: 1;
    }
}

/* ========================================
   MOBILE COLLAPSIBLE FILTERS
   ======================================== */

.mobile-filter-toggle {
    width: 100%;
    min-height: 48px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.mobile-filter-toggle:active {
    transform: scale(0.98);
}

.mobile-filter-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.mobile-filter-panel.open {
    max-height: 1000px;
}

.filter-panel-content {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* ========================================
   MOBILE RESULTS DISPLAY
   ======================================== */

.results-container {
    width: 100%;
    padding: 0;
}

.results-header {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 16px;
}

.results-count {
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
}

.no-results {
    text-align: center;
    padding: 32px 16px;
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.no-results-text {
    font-size: 1.125rem;
    color: #666;
    margin-bottom: 8px;
}

/* ========================================
   MOBILE TAB INTERFACE
   ======================================== */

.tab-content {
    padding: 16px;
}

/* ========================================
   MOBILE LOADING STATES
   ======================================== */

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   MOBILE ACCESSIBILITY
   ======================================== */

/* Focus indicators */
*:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 12px 20px;
    text-decoration: none;
    z-index: 1000;
}

.skip-to-content:focus {
    top: 0;
}

/* ========================================
   PROGRESSIVE ENHANCEMENT
   (Larger Phones: 375px+)
   ======================================== */

@media (min-width: 375px) {
    html {
        font-size: 17px;
    }

    .container {
        padding: 0 20px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.625rem;
    }

    .ordinance-card,
    .resolution-card,
    .document-card {
        padding: 20px;
    }
}

/* ========================================
   PROGRESSIVE ENHANCEMENT
   (Large Phones/Small Tablets: 480px+)
   ======================================== */

@media (min-width: 480px) {
    .container {
        padding: 0 24px;
    }

    .mobile-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }

    .period-filter-row {
        flex-direction: row;
        align-items: flex-end;
    }

    .period-filter-group {
        flex: 1;
    }

    .search-btn {
        width: auto;
        min-width: 120px;
    }
}

/* ========================================
   PROGRESSIVE ENHANCEMENT
   (Tablets: 768px+)
   ======================================== */

@media (min-width: 768px) {
    html {
        font-size: 18px;
    }

    .container {
        max-width: 720px;
        padding: 0 32px;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    .document-actions {
        flex-direction: row;
        gap: 16px;
    }

    .filter-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .mobile-filter-toggle {
        display: none; /* Show normal filters on tablet+ */
    }

    .mobile-filter-panel {
        max-height: none;
    }
}

/* ========================================
   PROGRESSIVE ENHANCEMENT
   (Desktop: 1024px+)
   ======================================== */

@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }

    .filter-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .mobile-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 24px;
    }
}

/* ========================================
   PROGRESSIVE ENHANCEMENT
   (Large Desktop: 1200px+)
   ======================================== */

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}
