@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Cores Principais - Forbiz Blue Theme */
    --primary: #002B49;
    --primary-hover: #001f35;
    --primary-light: #f0f7ff;
    --secondary: #0067B8;
    --secondary-hover: #005294;

    /* Cores de Fundo */
    --bg: #f8fafc;
    --bg-dark: #0f172a;
    --white: #ffffff;

    /* Cores de Texto */
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;

    /* Cores de Borda */
    --border: #e2e8f0;
    --border-dark: #cbd5e0;

    /* Cores de Estado */
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transições */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container Principal */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cabeçalho */
.header {
    padding: 30px 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #004e92 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.header h1 {
    font-size: 1.75rem;
    color: var(--white);
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.brand-logo {
    max-height: 70px;
    width: auto;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.brand-logo:hover {
    transform: scale(1.1) rotate(5deg);
}

/* Conteúdo */
.content {
    padding: 40px;
}

/* Barra de Ações */
.action-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

/* Botões */
.btn-action {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #005b96 100%);
    color: var(--white);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #004a7c 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, #3b82f6 100%);
    color: var(--white);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--secondary-hover) 0%, #2563eb 100%);
}

.btn-info {
    background: var(--white);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-info:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.btn-cancel {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-cancel:hover {
    background: #cbd5e0;
}

.btn-save {
    background: linear-gradient(135deg, var(--secondary) 0%, #667eea 100%);
    color: var(--white);
}

.btn-save:hover {
    background: linear-gradient(135deg, var(--secondary-hover) 0%, #5568d3 100%);
}

.btn-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Tabela */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--white);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 18px 20px;
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: linear-gradient(to right, rgba(0, 43, 73, 0.05), transparent);
}

/* Status Pills */
.status-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.active {
    background: var(--success-light);
    color: #22543d;
}

.inactive {
    background: var(--danger-light);
    color: #822727;
}

/* Loading */
.loading {
    display: inline-block;
    color: var(--text-muted);
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Modais - REMOVIDO PARA EVITAR CONFLITO COM COMPONENTS.CSS
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--white);
    margin: 2vh auto;
    width: 95%;
    max-width: 1200px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    max-height: 96vh;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-sm {
    max-width: 500px;
}

.modal-header {
    padding: 25px 35px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, var(--white), #f8fafc);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
}

.close-btn {
    cursor: pointer;
    font-size: 1.75rem;
    color: var(--text-muted);
    transition: var(--transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.close-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-body {
    padding: 35px;
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 35px;
    overflow-y: auto;
}

.modal-sm .modal-body {
    display: block;
}

.modal-footer {
    padding: 20px 35px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}
*/

/* Formulários */
.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text);
}

input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 20px;
    transition: var(--transition);
    background: var(--white);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 103, 184, 0.1);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Condições */
.conditions-section {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    padding: 25px;
    border-radius: 12px;
    border: 2px solid var(--border);
    margin-bottom: 25px;
}

.condition-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 40px;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    background: var(--white);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.condition-row:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(5px);
}

.condition-row select,
.condition-row input {
    margin-bottom: 0 !important;
}

.logic-connector {
    text-align: center;
    font-weight: 800;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: -6px 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-add-condition {
    background: var(--white);
    color: var(--text);
    border: 2px dashed var(--border-dark);
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-size: 0.95rem;
}

.btn-add-condition:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    border-style: solid;
}

.remove-row {
    color: var(--danger);
    cursor: pointer;
    font-size: 1.4rem;
    text-align: center;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.remove-row:hover {
    background: var(--danger-light);
    transform: scale(1.2);
}

/* Canais */
.channels-box {
    display: flex;
    gap: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: 8px;
    transition: var(--transition);
    background: var(--white);
    border: 2px solid transparent;
}

.channel-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.channel-item input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
}

/* Editor */
.editor-wrapper {
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.toolbar-vars {
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.var-tag {
    background: var(--white);
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: grab;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    user-select: none;
}

.var-tag:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.var-tag:active {
    cursor: grabbing;
}

#editTemplate {
    border: none;
    min-height: 220px;
    resize: vertical;
    margin-bottom: 0;
    padding: 20px;
    font-family: inherit;
    line-height: 1.6;
}

/* Preview */
.preview-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-title {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mock-phone {
    background: #e5ddd5;
    border-radius: 15px;
    padding: 25px;
    flex-grow: 1;
    border: 1px solid var(--border-dark);
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-size: cover;
    overflow-y: auto;
    min-height: 300px;
}

.msg-bubble {
    background: var(--white);
    padding: 14px 18px;
    border-radius: 0 12px 12px 12px;
    font-size: 0.9rem;
    max-width: 90%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    line-height: 1.5;
    white-space: pre-wrap;
    animation: bubbleIn 0.3s ease-out;
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.info-box {
    margin-top: 20px;
    padding: 18px;
    background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
    border-radius: 10px;
    border-left: 4px solid var(--info);
    font-size: 0.85rem;
    color: #2c5282;
    line-height: 1.6;
}

/* Toast */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 16px 24px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: linear-gradient(135deg, var(--success) 0%, #38a169 100%);
}

.toast.error {
    background: linear-gradient(135deg, var(--danger) 0%, #e53e3e 100%);
}

.toast.info {
    background: linear-gradient(135deg, var(--info) 0%, #3182ce 100%);
}

/* Responsivo */
@media (max-width: 1024px) {
    .modal-body {
        grid-template-columns: 1fr;
    }

    .preview-container {
        order: -1;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

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

    .form-grid {
        grid-template-columns: 1fr;
    }

    .condition-row {
        grid-template-columns: 1fr;
    }

    .channels-box {
        flex-direction: column;
    }

    .action-bar {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
        justify-content: center;
    }
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--secondary-hover) 100%);
}