/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.lead {
    font-size: 1.2em;
    font-weight: 300;
    color: #666;
    margin-bottom: 1.5em;
}

/* Header */
.site-header {
    background: #2c3e50;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.logo h1 {
    color: #fff;
    font-size: 1.4em;
    text-decoration: none;
    font-weight: 600;
}

.logo a {
    text-decoration: none;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 1.5em;
}

.main-nav a {
    text-decoration: none;
    color: #ecf0f1;
    font-weight: 400;
    font-size: 0.95em;
    transition: color 0.3s;
}

.main-nav a:hover {
    color: #3498db;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background: #ecf0f1;
    margin: 3px 0;
    transition: 0.3s;
}

.mobile-menu {
    display: none;
    background: #fff;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.mobile-menu ul {
    list-style: none;
    padding: 1em 0;
}

.mobile-menu a {
    display: block;
    padding: 0.8em 2em;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #eee;
}

/* Breadcrumbs */
.breadcrumbs {
    background: #ecf0f1;
    padding: 0.7em 0;
    font-size: 0.85em;
    border-bottom: 1px solid #d5d8dc;
}

.breadcrumbs ol {
    display: flex;
    list-style: none;
    align-items: center;
}

.breadcrumbs li::after {
    content: '›';
    margin: 0 0.5em;
    color: #666;
}

.breadcrumbs li:last-child::after {
    display: none;
}

.breadcrumbs a {
    color: #007bff;
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Main Content */
.main-content {
    padding: 2em 0;
    min-height: calc(100vh - 200px);
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.8em;
    color: #2c3e50;
}

h1 {
    font-size: 2.2em;
    color: #007bff;
}

h2 {
    font-size: 1.8em;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.3em;
}

p {
    margin-bottom: 1em;
}

.page-description {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 2em;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3em 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin: -2em -20px 2em -20px;
}

.hero-section h1 {
    color: white;
}

.hero-description {
    font-size: 1.2em;
    margin-bottom: 2em;
    opacity: 0.9;
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.search-form {
    display: flex;
    background: white;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.search-form input {
    flex: 1;
    padding: 1em 1.5em;
    border: none;
    font-size: max(16px, 1.1em); /* Prevent iOS zoom */
    outline: none;
}

.search-form input:focus {
    box-shadow: inset 0 0 0 2px #007bff;
}

.search-form button {
    display: none; /* Hide search button - search works as you type */
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-top: 0.5em;
    display: none;
    z-index: 100;
}

/* Stats Section */
.stats-section {
    margin: 3em 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2em;
    margin-top: 2em;
}

.stat-card {
    background: white;
    padding: 2em;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-number {
    font-size: 2.5em;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 0.2em;
}

.stat-label {
    color: #666;
    font-size: 1.1em;
}

/* Navigation Section */
.navigation-section {
    margin: 4em 0;
}

.states-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1em;
    margin-top: 2em;
}

.state-card {
    background: white;
    padding: 1.5em;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 44px; /* Minimum tap target */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.state-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-decoration: none;
    color: #333;
}

.state-abbr {
    font-size: 2em;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 0.2em;
}

/* Neighborhoods Section */
.neighborhoods-section {
    margin: 3em 0;
}

.neighborhoods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5em;
    margin-top: 2em;
}

.neighborhood-card {
    background: white;
    padding: 1.5em;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.neighborhood-card h3 {
    font-size: 1.1em;
    color: #2c3e50;
    margin: 0 0 0.5em 0;
}

.state-name {
    font-size: 0.9em;
    color: #666;
}

/* Quick Links */
.quick-links-section {
    margin: 4em 0;
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2em;
    margin-top: 2em;
}

.quick-link-card {
    background: white;
    padding: 2em;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.quick-link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    text-decoration: none;
    color: #333;
}

.quick-link-card h3 {
    color: #007bff;
    margin-bottom: 1em;
}

/* Tables */
.data-table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin: 2em 0;
}

.data-table th,
.data-table td {
    padding: 1em;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.data-table .center {
    text-align: center;
}

.state-link {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.state-link:hover {
    text-decoration: underline;
}

/* Cities by Letter */
.letter-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 2em 0;
    align-items: center;
}

.letter-link, .letter-box {
    padding: 0.5em 1em;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: background 0.3s;
}

.letter-link:hover, .letter-box:hover {
    background: #0056b3;
    text-decoration: none;
    color: white;
}

.letter-box {
    text-align: center;
    display: block;
}

.letter-box .letter {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
}

.letter-box .count {
    font-size: 0.8em;
    opacity: 0.9;
}

.letter-navigation.large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1em;
}

/* CEP Tables */
.ceps-table-container {
    overflow-x: auto;
    margin: 2em 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.ceps-table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    font-size: 0.95em;
}

.ceps-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ceps-table th {
    padding: 1em 1.2em;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ceps-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.ceps-table tbody tr:hover {
    background-color: #f8f9fa;
}

.ceps-table tbody tr:last-child {
    border-bottom: none;
}

.ceps-table td {
    padding: 1em 1.2em;
    vertical-align: middle;
}

.ceps-table td:first-child {
    font-weight: 500;
}

.ceps-table .cep-code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.05em;
    color: #2c3e50;
    font-weight: 600;
}

.ceps-table a.cep-code {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.ceps-table a.cep-code:hover {
    color: #764ba2;
    text-decoration: underline;
}

.special-cep-note {
    color: #6c757d;
    font-size: 0.9em;
    font-style: italic;
}

/* Cities and CEPs Lists */
.cities-list, .cep-list {
    columns: 3;
    column-gap: 2em;
    list-style: none;
}

.cities-list li, .cep-list li {
    margin-bottom: 0.5em;
    break-inside: avoid;
}

.cities-list a, .cep-list a {
    color: #007bff;
    text-decoration: none;
}

.cities-list a:hover, .cep-list a:hover {
    text-decoration: underline;
}

.cep-count {
    color: #666;
    font-size: 0.9em;
}

/* Inline CEPs (for cities with < 10 CEPs) */
.ceps-inline {
    background: white;
    padding: 2em;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.ceps-inline .cep-list {
    columns: 1;
    list-style: disc;
    margin-left: 1.5em;
}

/* CEP codes in neighborhoods (non-clickable for small cities) */
.neighborhood-card .cep-code {
    display: inline-block;
    padding: 0.4em 0.7em;
    margin: 0.3em 0.2em;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    font-weight: 600;
    color: #2c3e50;
}

/* CEP list in neighborhood cards */
.neighborhood-card .cep-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3em;
    margin-top: 0.5em;
    align-items: center;
}

/* Neighborhood links for large cities */
.neighborhood-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, background 0.2s;
    min-height: 44px; /* Minimum tap target */
    padding: 0.8em;
    margin: -0.8em; /* Negative margin to maintain visual spacing */
    border-radius: 8px;
}

.neighborhood-link:hover {
    transform: translateY(-2px);
    text-decoration: none;
    background: rgba(0, 123, 255, 0.05);
}

.neighborhood-link:active {
    transform: translateY(0);
    background: rgba(0, 123, 255, 0.1);
}

.neighborhood-link h3 {
    color: #007bff;
    margin: 0.5em 0 0.2em 0;
}

.neighborhood-link:hover h3 {
    text-decoration: underline;
}

/* Info Section */
.info-section {
    background: white;
    padding: 2em;
    border-radius: 10px;
    margin: 3em 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Footer */
.site-footer {
    background: #2c3e50;
    color: white;
    padding: 3em 0 1em 0;
    margin-top: 4em;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2em;
    margin-bottom: 2em;
}

.footer-section h3 {
    color: #fff;
    margin-bottom: 1em;
    font-size: 1.2em;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: #bdc3c7;
    text-decoration: none;
    line-height: 1.8;
}

.footer-section a:hover {
    color: white;
    text-decoration: underline;
}

.footer-bottom {
    border-top: 1px solid #34495e;
    padding-top: 2em;
    text-align: center;
    color: #bdc3c7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .main-nav {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    /* Make search full-width and more prominent on mobile */
    .search-form {
        border-radius: 8px;
    }

    .search-form input {
        padding: 0.9em 1.2em;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .search-form button {
        display: none; /* Hidden on mobile too */
    }
    
    .mobile-menu.active {
        display: block;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
    
    .hero-section {
        padding: 2em 1em;
        margin: -2em -15px 2em -15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1em;
    }
    
    .states-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.8em;
    }
    
    .quick-links-grid {
        grid-template-columns: 1fr;
    }
    
    .cities-list {
        columns: 1;
    }
    
    .letter-navigation.large {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
    
    /* Convert tables to card layout on mobile */
    .ceps-table {
        border: none;
    }

    .ceps-table thead {
        display: none;
    }

    .ceps-table tbody {
        display: block;
    }

    .ceps-table tr {
        display: block;
        margin-bottom: 1em;
        background: white;
        border-radius: 8px;
        padding: 1em;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        border: none;
    }

    .ceps-table td {
        display: block;
        text-align: left !important;
        padding: 0.4em 0;
        border: none;
    }

    .ceps-table td:before {
        content: attr(data-label);
        font-weight: bold;
        display: inline-block;
        min-width: 100px;
        color: #495057;
    }

    .data-table {
        font-size: 0.9em;
    }

    .data-table th,
    .data-table td {
        padding: 0.7em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }
    
    .search-form input {
        padding: 0.8em 1em;
        font-size: 1em;
    }
    
    .state-card {
        padding: 1em;
    }
    
    .state-abbr {
        font-size: 1.5em;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5em;
    }
}

/* Map Styles */
.map-section {
    margin: 2em 0;
}

.postal-map {
    height: 500px;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 1em 0;
}

.map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 500px;
    background: #f0f0f0;
    border-radius: 8px;
    color: #666;
    font-size: 1.1em;
}

.map-loading::before {
    content: "Carregando mapa...";
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

.map-popup {
    padding: 1em;
    min-width: 200px;
}

.map-popup h4 {
    margin: 0 0 0.5em 0;
    color: #007bff;
    font-size: 1.1em;
}

.map-popup p {
    margin: 0.3em 0;
    font-size: 0.95em;
    color: #666;
}

.map-popup a {
    display: inline-block;
    margin-top: 0.5em;
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.map-popup a:hover {
    text-decoration: underline;
}

/* Mobile map adjustments */
@media (max-width: 768px) {
    /* Hide Brazil overview map on mobile homepage */
    .hero-section + .map-section {
        display: none;
    }

    .postal-map {
        height: 400px;
    }

    .map-section {
        margin: 1.5em 0;
    }
}

@media (max-width: 480px) {
    .postal-map {
        height: 350px;
    }
}

/* Map note for GPS coordinates */
.map-note {
    margin-top: 0.5em;
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

/* Copy CEP button */
.copy-cep-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.5em 0.9em;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
    margin-left: 0.6em;
    white-space: nowrap;
    vertical-align: middle;
}

/* Copy button in table cells */
.ceps-table .copy-cep-btn {
    font-size: 0.8em;
    padding: 0.4em 0.8em;
}

/* Copy button in neighborhood cards */
.neighborhood-card .copy-cep-btn {
    font-size: 0.75em;
    padding: 0.35em 0.7em;
    margin-left: 0.4em;
}

.copy-cep-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.copy-cep-btn:active {
    transform: translateY(0);
}

.copy-cep-btn.copied {
    background: #17a2b8;
}

.copy-cep-btn svg {
    width: 16px;
    height: 16px;
}

/* Share CEP Button */
.share-cep-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.4em 0.8em;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s, transform 0.1s;
    min-height: 36px;
    vertical-align: middle;
    margin-left: 0.5em;
}

.share-cep-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.share-cep-btn:active {
    transform: translateY(0);
}

.share-cep-btn svg {
    width: 16px;
    height: 16px;
}

/* Toast notification for copy feedback */
.copy-toast {
    position: fixed;
    bottom: 2em;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 1em 1.5em;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}