/*
Theme Name: PlattaData
Theme URI: https://plattadata.com.br
Author: PlattaData
Description: Tema para o sistema de busca de CNPJs e empresas brasileiras
Version: 1.0.2
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: plattadata
Tags: custom-background, custom-logo, custom-menu, featured-images
Requires at least: 6.9
Tested up to: 6.9.4
Requires PHP: 8.0
*/

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #dc2626;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --info-text: #1e40af;
    --dark: #1f2937;
    --light: #f3f4f6;
    --gray: #6b7280;
    --border: #e5e7eb;
    --white: #ffffff;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --border: #2d3748;
    --white: #1a1a2e;
    --dark: #eaeaea;
    --light: #16213e;
    --success-bg: #064e3b;
    --success-text: #6ee7b7;
    --danger-bg: #7f1d1d;
    --danger-text: #fca5a5;
    --danger: #fca5a5;
    --warning-bg: #78350f;
    --warning-text: #fcd34d;
    --warning: #fcd34d;
    --info-bg: #1e3a5f;
    --info-text: #93c5fd;
    --info: #93c5fd;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --bg-tertiary: #0f3460;
        --text-primary: #eaeaea;
        --text-secondary: #b0b0b0;
        --text-muted: #808080;
        --primary: #3b82f6;
        --primary-dark: #2563eb;
        --border: #2d3748;
        --white: #1a1a2e;
        --dark: #eaeaea;
        --light: #16213e;
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode,
body.dark-mode #page {
    background: var(--bg-primary);
    color: var(--text-primary);
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--dark);
    margin: 0 0 1rem;
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-branding .site-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.site-branding .site-title a {
    color: var(--dark);
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
}

.main-navigation a {
    color: var(--dark);
    font-weight: 500;
}

.main-navigation a:hover {
    color: var(--primary);
}

.search-section {
    padding: 3rem 0;
}

.search-header {
    text-align: center;
    margin-bottom: 2rem;
}

.search-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.search-header .subtitle {
    color: var(--gray);
    font-size: 1.125rem;
}

.search-form {
    max-width: 600px;
    margin: 0 auto 2rem;
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
}

.search-input-group input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.search-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-filters {
    margin-top: 1rem;
}

.search-filters select {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    min-width: 200px;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    background: var(--primary);
    color: var(--white);
}

.btn:hover {
    background: var(--primary-dark);
    color: var(--white);
}

.btn-primary {
    background: var(--primary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--dark);
}

.btn-outline:hover {
    background: var(--light);
}

.company-result {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.company-result h2 {
    margin-bottom: 0.5rem;
}

.company-result .cnpj {
    color: var(--gray);
    font-family: monospace;
    font-size: 0.875rem;
}

.company-result .location {
    color: var(--gray);
    font-size: 0.875rem;
}

.search-results {
    margin-top: 2rem;
}

.search-results .loading,
.search-results .error,
.search-results .no-results {
    text-align: center;
    color: var(--gray);
    padding: 2rem;
}

.site-footer {
    background: var(--dark);
    color: var(--white);
    padding: 2rem 0;
    margin-top: 3rem;
}

.site-footer a {
    color: var(--white);
}

.site-footer a:hover {
    color: var(--primary);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        text-align: center;
    }
    
    .main-navigation ul {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-input-group {
        flex-direction: column;
    }
    
    .search-header h1 {
        font-size: 1.75rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
    }
}

.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Página de detalhes da empresa */
.breadcrumb-nav {
    padding: 1rem 0;
    font-size: 0.875rem;
    color: var(--gray);
}

.breadcrumb-nav a {
    color: var(--primary);
}

.breadcrumb-nav span {
    margin: 0 0.5rem;
}

.company-detail {
    max-width: 800px;
}

.company-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.company-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.company-type {
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.company-cnpj {
    font-family: monospace;
    font-size: 1.125rem;
    color: var(--primary);
}

.company-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.company-status.status-ativa {
    background: #d1fae5;
    color: #065f46;
}

.company-status.status-inativa {
    background: #fee2e2;
    color: #991b1b;
}

.company-info,
.company-partners,
.company-changes {
    margin-bottom: 2rem;
}

.company-info h2,
.company-partners h2,
.company-changes h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    padding: 1rem;
    background: var(--light);
    border-radius: 0.375rem;
}

.info-item strong {
    display: block;
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.info-item span {
    font-size: 1rem;
    font-weight: 500;
}

.partners-list,
.changes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.partner-item,
.change-item {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.partner-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.partner-details {
    font-size: 0.875rem;
    color: var(--gray);
}

.partner-details span {
    margin-right: 1rem;
}

.company-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    margin-bottom: 1rem;
}

/* Dark Mode Adjustments */
[data-theme="dark"] .site-header,
[data-theme="dark"] .site-footer {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="dark"] .site-title a,
[data-theme="dark"] .main-navigation a {
    color: var(--text-primary);
}

[data-theme="dark"] .search-form input[type="search"],
[data-theme="dark"] .search-form input[type="text"] {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .btn,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-secondary {
    color: #fff;
}

[data-theme="dark"] .info-section div[style*="background: #f9fafb"] {
    background: var(--bg-secondary) !important;
}

[data-theme="dark"] .company-detail-content {
    background: var(--bg-primary);
}

[data-theme="dark"] .info-item strong,
[data-theme="dark"] .company-header h1 {
    color: var(--text-primary);
}

[data-theme="dark"] .info-item span {
    color: var(--text-secondary);
}

[data-theme="dark"] .site-footer {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

[data-theme="dark"] .breadcrumb-nav a {
    color: var(--primary);
}

[data-theme="dark"] .badge-success {
    background: #065f46;
    color: #6ee7b7;
}

[data-theme="dark"] .badge-secondary {
    background: #374151;
    color: #9ca3af;
}

/* Dark Mode Classes for inline styles */
body.dark-mode .card-bg,
body.dark-mode [style*="background: #f9fafb"],
body.dark-mode [style*="background:#f9fafb"],
body.dark-mode [style*="background: #f3f4f6"],
body.dark-mode [style*="background:#f3f4f6"] {
    background: var(--bg-secondary) !important;
}

body.dark-mode [style*="background: #fff"],
body.dark-mode [style*="background:#fff"] {
    background: var(--bg-primary) !important;
}

body.dark-mode .text-primary,
body.dark-mode [style*="color: #1f2937"],
body.dark-mode [style*="color:#1f2937"],
body.dark-mode [style*="color: #374151"],
body.dark-mode [style*="color:#374151"] {
    color: var(--text-primary) !important;
}

body.dark-mode .text-secondary,
body.dark-mode [style*="color: #6b7280"],
body.dark-mode [style*="color:#6b7280"] {
    color: var(--text-secondary) !important;
}

body.dark-mode .text-muted,
body.dark-mode [style*="color: #9ca3af"],
body.dark-mode [style*="color:#9ca3af"] {
    color: var(--text-muted) !important;
}

body.dark-mode .text-link,
body.dark-mode [style*="color: #2563eb"] {
    color: var(--primary) !important;
}

body.dark-mode .border-color,
body.dark-mode [style*="border: 1px solid #e5e7eb"],
body.dark-mode [style*="border-bottom: 1px solid #e5e7eb"],
body.dark-mode [style*="border-bottom: 1px solid #f3f4f6"] {
    border-color: var(--border) !important;
}

body.dark-mode .bg-success-light {
    background: #064e3b !important;
    color: #6ee7b7 !important;
}

body.dark-mode .bg-info-light {
    background: #1e3a5f !important;
    color: #60a5fa !important;
}

body.dark-mode .btn-primary {
    background: var(--primary) !important;
    color: #fff !important;
}

body.dark-mode .btn-secondary {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

body.dark-mode .btn-danger {
    background: #dc2626 !important;
    color: #fff !important;
}

body.dark-mode .btn-gray {
    background: #4b5563 !important;
    color: #fff !important;
}

/* Footer Dark Mode */
body.dark-mode .site-footer {
    background: var(--bg-secondary);
    border-color: var(--border);
}

body.dark-mode .site-footer,
body.dark-mode .footer-info,
body.dark-mode .footer-info p,
body.dark-mode .footer-content {
    color: var(--text-secondary) !important;
}

body.dark-mode .footer-links a,
body.dark-mode .site-footer a {
    color: var(--primary) !important;
}

body.dark-mode .footer-links li a,
body.dark-mode .footer-menu a {
    color: var(--text-secondary) !important;
}

body.dark-mode .footer-menu li {
    color: var(--text-secondary);
}

/* Search Form Dark Mode */
body.dark-mode .search-form {
    background: var(--bg-primary);
}

body.dark-mode .search-input {
    background: var(--bg-secondary) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

/* Buttons */
body.dark-mode .btn-primary {
    background: var(--primary);
    color: #fff;
}

body.dark-mode .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
}

/* Company Detail */
body.dark-mode .company-detail {
    background: var(--bg-primary);
}

body.dark-mode .company-header {
    border-color: var(--border);
}

body.dark-mode .breadcrumb-nav {
    color: var(--text-secondary);
}

body.dark-mode .breadcrumb-nav a {
    color: var(--primary);
}

/* Company Header */
body.dark-mode .company-detail-page,
body.dark-mode .company-header-section {
    background: var(--bg-primary) !important;
}

body.dark-mode .company-name {
    color: var(--text-primary) !important;
}

body.dark-mode .company-legal-name {
    color: var(--text-secondary) !important;
}

body.dark-mode .company-cnpj {
    color: var(--primary) !important;
}

/* Atividade Principal - #eff6ff */
body.dark-mode [style*="background: #eff6ff"],
body.dark-mode [style*="background:#eff6ff"] {
    background: #1e3a5f !important;
    border-left-color: var(--primary) !important;
}

body.dark-mode [style*="color: #374151"],
body.dark-mode [style*="color:#374151"] {
    color: var(--text-primary) !important;
}

/* Tributação - #d1fae5 */
body.dark-mode [style*="background: #d1fae5"],
body.dark-mode [style*="background:#d1fae5"] {
    background: #064e3b !important;
    color: #6ee7b7 !important;
}

/* Status Badge */
body.dark-mode .status-badge {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Visualizações */
body.dark-mode [style*="color: #6b7280"],
body.dark-mode [style*="color:#6b7280"] {
    color: var(--text-secondary) !important;
}

/* Atividade principal container */
body.dark-mode .company-detail-content {
    background: var(--bg-primary);
}

/* CNAE code */
body.dark-mode .cnae-code {
    color: var(--text-primary);
}

/* Link email */
body.dark-mode a[href^="mailto:"] {
    color: var(--primary);
}

/* Endereço */
body.dark-mode .info-section:has(> h3:contains("ENDEREÇO")) > div,
body.dark-mode [style*="ENDEREÇO"] ~ div {
    background: var(--bg-secondary) !important;
}

body.dark-mode [style*="color: #1f2937"]:has(+ *) {
    color: var(--text-primary) !important;
}

/* Sócios */
body.dark-mode .company-partners {
    background: var(--bg-primary);
}

body.dark-mode .partner-item {
    background: var(--bg-secondary) !important;
    border-color: var(--border) !important;
}

body.dark-mode .partner-item div:first-child {
    color: var(--text-primary) !important;
}

body.dark-mode .partner-item div:last-child {
    color: var(--text-secondary) !important;
}

body.dark-mode .section-title,
body.dark-mode h3:contains("Sócios") {
    color: var(--text-primary) !important;
}

/* Links Externos */
body.dark-mode .external-link,
body.dark-mode a[target="_blank"] {
    color: var(--primary) !important;
}

body.dark-mode [style*="color: #2563eb"] {
    color: var(--primary) !important;
}

/* Sócios title - important to override inline styles */
body.dark-mode .section-title,
body.dark-mode .company-partners h3,
body.dark-mode h3.section-title,
body.dark-mode h3[class*="section-title"] {
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

/* All h3 in company-partners */
body.dark-mode .company-partners > h3 {
    color: var(--text-primary) !important;
}