/* Global Styles */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #43e97b;
    --danger-color: #ff5252;
    --warning-color: #ffd700;
    --info-color: #4facfe;
    --dark-color: #333;
    --light-color: #f5f5f5;
    --white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background: var(--light-color);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

a:hover {
    color: var(--secondary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-secondary {
    background: #e0e0e0;
    color: var(--dark-color);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
}

/* Botões em modais: tamanho mínimo para não cortar texto (Salvar Alterações, Enviar email, Abrir WhatsApp) */
.btn-modal-primary {
    min-width: 200px;
    min-height: 48px;
    padding: 14px 24px;
    white-space: nowrap;
}
.btn-modal-secondary {
    min-height: 48px;
    padding: 14px 24px;
    min-width: 100px;
}

.card-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--dark-color);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* Loading spinner */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-in-up {
    animation: slideInUp 0.5s ease-out;
}

.slide-in-down {
    animation: slideInDown 0.5s ease-out;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #111827;
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.sidebar .logo h2 {
    font-size: 20px;
    margin: 0;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    color: var(--white);
    padding: 10px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
}

.nav-item.active,
.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
}

.main-content {
    flex: 1;
    padding: 30px 40px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stats-grid,
.charts-grid,
.cards-grid,
.tools-grid {
    display: grid;
    gap: 20px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 20px;
}

.charts-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.cards-grid,
.tools-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stat-card,
.tool-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.stat-card {
    display: flex;
    gap: 14px;
}

.stat-card.map-place-new {
    border-left: 4px solid #22c55e;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
}

.tool-card button {
    margin-top: 12px;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 24px;
}

.pre-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 10px;
    min-height: 120px;
    white-space: pre-wrap;
}

/* Facebook Ads – relatório em secções (letras bem legíveis e visíveis) */
.facebook-plan-output {
    margin-top: 12px;
}
.facebook-plan-section {
    background: #fff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    padding: 22px 26px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    font-size: 1.1rem;
    color: #1e293b;
}
.facebook-plan-section h4 {
    margin: 0 0 16px 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #3730a3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.facebook-plan-section .copy-btn {
    padding: 10px 16px;
    font-size: 1rem;
    border-radius: 8px;
    background: #6366f1;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.facebook-plan-section .copy-btn:hover {
    background: #4f46e5;
}
.facebook-plan-section .copyable {
    background: #f8fafc;
    border-radius: 10px;
    padding: 20px 22px;
    white-space: pre-wrap;
    font-size: 1.2rem;
    line-height: 1.75;
    margin-bottom: 14px;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-weight: 500;
}
.facebook-plan-section p,
.facebook-plan-section li {
    font-size: 1.15rem;
    line-height: 1.75;
    color: #1e293b;
    font-weight: 500;
}
.facebook-plan-section ul {
    margin: 0 0 0 22px;
    padding: 0 0 10px 0;
}
.facebook-plan-section li {
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    .dashboard-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .main-content {
        padding: 20px;
    }
}

/* ============================================================================
   MODAL STYLES - ESSENCIAL PARA FUNCIONAMENTO
   ============================================================================ */

.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 9999; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.8); /* Black w/ opacity */
    backdrop-filter: blur(3px);
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    background-color: #fefefe;
    margin: 2% auto; /* 2% from the top and centered */
    padding: 20px;
    border: none;
    border-radius: 12px;
    width: 90%; /* Could be more or less, depending on screen size */
    max-width: 800px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 8px 24px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease-out;
    position: relative;
}

/* Modal animation */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* Close Button */
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close:hover,
.close:focus {
    color: #ff4444;
    text-decoration: none;
    transform: scale(1.2);
}

/* Active Modal */
.modal.active {
    display: block !important;
}

/* Modais Prospeção por Área: sempre à frente (sidebar e outros têm stacking context) */
#mapPlaceDataModal,
#mapPlaceToLeadModal {
    z-index: 99999;
}
#mapPlaceDataModal .modal-content,
#mapPlaceToLeadModal .modal-content {
    position: relative;
    z-index: 100000;
}

/* Modal Dados do contacto – layout em campos */
.map-place-data-modal-content .map-place-data-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.map-place-data-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.75rem;
    align-items: start;
}
.map-place-data-row-actions { align-items: center; }
.map-place-data-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.map-place-data-value {
    font-size: 0.95rem;
    color: #1e293b;
    word-break: break-word;
}
.map-place-data-value a {
    color: #6366f1;
    text-decoration: none;
}
.map-place-data-value a:hover {
    text-decoration: underline;
}
.map-place-data-value .muted {
    color: #94a3b8;
    font-style: italic;
}
.map-place-data-hint {
    font-size: 0.85rem;
    margin-top: 1rem;
    margin-bottom: 0;
}
@media (max-width: 480px) {
    .map-place-data-row { grid-template-columns: 1fr; }
}

/* Modal responsiveness */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
        max-height: 90vh;
        overflow-y: auto;
    }
}
