/* style.css v3 - Menu com texto preto, botão branco */
:root {
    --primary-color: #0066cc;
    --secondary-color: #00529c;
    --accent-color: #ff6b00;
    --bg-color: #f5f5f5;
    --text-color: #333;
    --border-color: #ddd;
    --header-bg: #003d7a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-list.active {
    display: block;
}

.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f5f5f5;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item small {
    color: #666;
    font-size: 0.85em;
}

/* Login Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
}

.modal-content input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.login-error {
    color: #c33;
    background: #fee;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--header-bg) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.logo {
    height: 45px;
    width: auto;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.auth-section button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 1.2rem;
}

.auth-section button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content */
main {
    padding: 40px 0;
    min-height: calc(100vh - 200px);
}

/* Search Section */
.search-section {
    background: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.search-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-color);
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab:hover {
    color: var(--primary-color);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.search-form {
    display: none;
}

.search-form.active {
    display: block;
}

.search-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-box input {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    outline: none;
    transition: border-color 0.3s;
}

.search-box input:focus {
    border-color: var(--primary-color);
}

.help-icon {
    font-size: 1.2rem;
    cursor: help;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.help-icon:hover {
    opacity: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 102, 204, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

/* Menu dropdown */
.auth-section {
    position: relative;
}

.menu-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    color: white;
    transition: opacity 0.2s;
}

.menu-btn:hover {
    opacity: 0.7;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 120px;
    z-index: 1000;
    margin-top: 5px;
}

.menu-item {
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333 !important;
    transition: background 0.2s;
}

.menu-item:hover {
    background: #f5f5f5;
    color: #000 !important;
}

.btn-icon {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.3rem;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}



/* Advanced Form */
.advanced-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Results Section */
.results-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.results-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 15px;
}

.results-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 15px;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
    color: #666;
}

.search-time {
    font-style: italic;
    color: #999;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.cep-column {
    white-space: nowrap;
    min-width: 100px;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error */
.error {
    background: #fee;
    border: 2px solid #fcc;
    color: #c33;
    padding: 20px;
    border-radius: 5px;
    margin-top: 20px;
}

/* Footer */
footer {
    background: var(--header-bg);
    color: white;
    padding: 20px 0;
    text-align: center;
    margin-top: 40px;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    max-width: 90%;
    width: 400px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.install-content p {
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-color);
}

.install-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.install-buttons button {
    font-size: 0.9rem;
    padding: 10px 20px;
}

/* Responsive Design - Mobile First */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .logo {
        height: 40px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 10px 0;
    }

    .header-content {
        gap: 10px;
    }

    .logo {
        height: 35px;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .auth-section button {
        padding: 6px 12px;
        font-size: 1rem;
    }

    .search-section {
        padding: 20px 15px;
    }

    .search-tabs {
        flex-wrap: wrap;
        gap: 5px;
    }

    .tab {
        padding: 10px 15px;
        font-size: 0.9rem;
        flex: 1;
        min-width: calc(33.33% - 5px);
    }

    .search-box {
        flex-direction: column;
    }

    .search-box input {
        font-size: 1rem;
        padding: 12px 15px;
    }

    .btn-primary {
        padding: 12px 30px;
        font-size: 1rem;
        width: 100%;
    }

    .btn-secondary {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .advanced-form {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .results-section {
        padding: 20px 15px;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .results-header h2 {
        font-size: 1.3rem;
    }

    .results-header button {
        width: 100%;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85rem;
        min-width: 600px;
    }

    th, td {
        padding: 8px 10px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .search-tips {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .install-prompt {
        bottom: 10px;
        max-width: 95%;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .logo {
        height: 35px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .search-section {
        padding: 15px 10px;
    }

    .tab {
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .search-box input {
        font-size: 0.95rem;
        padding: 10px 12px;
    }

    .btn-primary {
        padding: 10px 20px;
        font-size: 0.95rem;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 6px 8px;
    }

    .results-header h2 {
        font-size: 1.1rem;
    }

    .search-tips ul {
        font-size: 0.85rem;
    }

    .install-buttons {
        flex-direction: column;
    }

    .install-buttons button {
        width: 100%;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn-primary,
    .btn-secondary,
    .tab,
    .pagination button {
        min-height: 44px;
        min-width: 44px;
    }

    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding: 10px 0;
    }

    .header-content {
        flex-direction: row;
        justify-content: space-between;
    }

    .logo {
        height: 30px;
    }

    header h1 {
        font-size: 1rem;
    }

    main {
        padding: 20px 0;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Dark mode support (system preference) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #e0e0e0;
        --border-color: #444;
    }

    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }

    .search-section,
    .results-section {
        background: #2a2a2a;
    }

    .search-box input,
    .form-group input {
        background: #333;
        color: var(--text-color);
        border-color: #555;
    }

    .search-tips {
        background: #333;
    }

    tbody tr:hover {
        background-color: #333;
    }

    .install-prompt {
        background: #2a2a2a;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
