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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

/* Layout Principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.timezone-info {
    background: rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 0.9rem;
}

/* Toast de Notificações */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: #4caf50;
}

.toast.error {
    background: #f44336;
}

/* Seções */
.content {
    padding: 30px;
}

.section {
    margin-bottom: 40px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.section-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.section-header h2 {
    color: #495057;
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.section-header p {
    color: #6c757d;
    font-size: 0.9rem;
}

.section-content {
    padding: 25px;
}

/* Formulários */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-col {
    flex: 1;
    min-width: 250px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

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

.textarea-large {
    min-height: 200px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.field-description {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 5px;
}

/* Checkboxes e Toggles */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Chips/Tags */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    min-height: 45px;
}

.chip {
    background: #667eea;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chip-remove {
    cursor: pointer;
    font-weight: bold;
}

.chip-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 100px;
    padding: 5px;
}

/* Tabelas */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

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

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

/* Botões */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

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

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5a6fd8;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid #667eea;
    color: #667eea;
}

.btn-outline:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.btn-large {
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

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

.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

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

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

/* Logs */
.logs-panel {
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    padding: 20px;
    margin-top: 30px;
}

.logs-content {
    background: #2d3748;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
}

/* Responsivo */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .content {
        padding: 20px;
    }

    .section-content {
        padding: 15px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-col {
        min-width: auto;
    }

    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
}

/* Estados de erro */
.error {
    border-color: #dc3545 !important;
}

.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    min-height: 1em;
}

/* Resumo */
.summary-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-weight: 500;
    color: #495057;
}

.summary-value {
    color: #6c757d;
}

.header-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-label {
    font-weight: bold;
}

/* Estilos para checkboxes customizados */
.checkbox-item {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 16px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Esconde o checkbox padrão */
.checkbox-item input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Cria o checkmark customizado */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border-radius: 5px; /* Opcional: para bordas arredondadas */
}

/* Quando o checkbox está marcado, adiciona um background azul */
.checkbox-item input:checked ~ .checkmark {
    background-color: #667eea;
}

/* Cria o indicador/checkmark (escondido por padrão) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

/* Mostra o indicador quando o checkbox está marcado */
.checkbox-item input:checked ~ .checkmark:after {
    display: block;
}

/* Estilo do indicador/checkmark */
.checkbox-item .checkmark:after {
    left: 9px;
    top: 5px;
    width: 7px;
    height: 13px;
    border: solid white;
    border-width: 0 3px 3px 0;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}

/* --- NOVOS ESTILOS PARA O TEMPLATE BUILDER --- */

.template-builder-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-top: 20px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.tab-link {
    padding: 15px 20px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-link.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    padding: 25px;
}

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

.template-fields {
    display: none;
}

.sections-editor {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px dashed #ced4da;
}

#sections-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.section-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
}

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

.section-card-header .form-group {
    flex-grow: 1;
    margin-bottom: 0;
}

.section-actions, .row-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: 1px solid #ced4da;
    color: #495057;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.action-btn.delete-btn:hover {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.rows-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-left: 20px;
    border-left: 2px solid #e0e0e0;
}

.row-card {
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 15px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.row-fields {
    flex-grow: 1;
}

.row-fields .form-group {
    margin-bottom: 10px;
}
.row-fields .form-group:last-child {
    margin-bottom: 0;
}

.json-preview-area {
    background: #2d3748;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
}