/* ============================================
   FORMBUILDER — ESTILO GLOBAL
   ============================================ */
:root {
    --theme: #4285f4;
    --bg: #f6f8fc;
    --card: #ffffff;
    --text: #202124;
    --muted: #5f6368;
    --border: #e0e3e7;
    --shadow: 0 1px 3px rgba(60,64,67,.15), 0 4px 8px rgba(60,64,67,.08);
    --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--theme); text-decoration: none; }
h1, h2, h3 { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ============================================
   BOTÕES
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all .15s;
    white-space: nowrap;
    font-family: inherit;
}
.btn:hover { background: #f1f3f4; }
.btn.primary { background: var(--theme); color: #fff; border-color: var(--theme); }
.btn.primary:hover { filter: brightness(0.92); }
.btn.danger { background: #fce8e6; color: #c5221f; border-color: transparent; }
.btn.danger:hover { background: #f8d7d4; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }
.btn.full { width: 100%; }
.btn.big { padding: 14px; font-size: 1rem; }

/* ============================================
   LOGIN
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea, #764ba2);
}
.login-card {
    background: #fff;
    padding: 42px;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 100%;
    max-width: 420px;
}
.login-card .logo { font-size: 1.4rem; font-weight: 700; color: var(--theme); margin-bottom: 20px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin-bottom: 24px; }
.login-card label { display: block; font-size: 0.85rem; font-weight: 500; margin: 14px 0 6px; }
.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}
.login-card input:focus {
    outline: none;
    border-color: var(--theme);
    box-shadow: 0 0 0 3px rgba(66,133,244,.15);
}
.login-card button { margin-top: 20px; }
.hint { text-align: center; margin-top: 18px; font-size: 0.82rem; color: var(--muted); }
.alert { padding: 12px; border-radius: 8px; margin-bottom: 14px; font-size: 0.9rem; }
.alert.error { background: #fce8e6; color: #c5221f; }

/* ============================================
   HEADER ADMIN
   ============================================ */
.admin-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text) !important; }
.admin-header nav { display: flex; align-items: center; gap: 16px; }
.user { font-size: 0.9rem; color: var(--muted); }

.container { max-width: 1240px; margin: 0 auto; padding: 32px 24px; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 1.8rem; }
.back-link { font-size: 0.85rem; color: var(--muted); }

/* ============================================
   STATS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

/* ============================================
   GRID DE FORMULÁRIOS (DASHBOARD)
   ============================================ */
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.form-card {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
}
.form-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(60,64,67,.15); }
.form-card-header { height: 8px; }
.form-card-body { padding: 20px; flex: 1; }
.form-card-body h3 { font-size: 1.1rem; margin-bottom: 6px; }
.form-card-body p { font-size: 0.85rem; margin-bottom: 14px; color: var(--muted); }
.form-meta { display: flex; gap: 14px; font-size: 0.82rem; color: var(--muted); }
.form-card-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    background: #fff;
    border-radius: var(--radius);
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
}
.modal-content h2 { margin-bottom: 18px; }
.modal-content label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 6px; }
.modal-content input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

/* ============================================
   EDITOR DE FORMULÁRIO
   ============================================ */
.editor-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}
.editor-sidebar {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: sticky;
    top: 90px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.editor-sidebar h3 {
    font-size: 0.95rem;
    margin: 0 0 4px;
    color: var(--text);
    font-weight: 600;
}
.editor-sidebar h3:not(:first-child) {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.editor-sidebar label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 8px;
    font-weight: 500;
}
.editor-sidebar input[type="color"] {
    width: 100%;
    height: 46px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 3px;
    background: #fff;
}
.editor-sidebar input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.78rem;
    font-family: monospace;
    background: #f8f9fa;
    color: var(--muted);
}

.editor-main {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}
.editor-toolbar {
    display: flex;
    gap: 12px;
    background: #fff;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    align-items: center;
}
.editor-toolbar input {
    flex: 1;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    background: #fff;
    min-width: 0;
    font-family: inherit;
}
.editor-toolbar input:focus {
    outline: none;
    border-color: var(--theme);
    box-shadow: 0 0 0 3px rgba(66,133,244,.15);
}
.editor-toolbar .btn {
    flex-shrink: 0;
    padding: 12px 22px;
}

.editor-main > textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-family: inherit;
    background: #fff;
    resize: vertical;
    min-height: 70px;
    box-shadow: var(--shadow);
}
.editor-main > textarea:focus {
    outline: none;
    border-color: var(--theme);
    box-shadow: 0 0 0 3px rgba(66,133,244,.15);
}

#questionsList {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.question-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 16px;
    border-left: 4px solid var(--theme);
    align-items: flex-start;
    transition: box-shadow .2s;
}
.question-card:hover {
    box-shadow: 0 4px 16px rgba(60,64,67,.15);
}
.q-drag {
    cursor: grab;
    color: #c0c4c8;
    font-size: 1.3rem;
    padding: 8px 4px 0 0;
    user-select: none;
    flex-shrink: 0;
}
.q-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}
.q-label {
    padding: 12px 4px;
    border: none;
    border-bottom: 2px solid var(--border);
    font-size: 1.02rem;
    font-weight: 500;
    background: transparent;
    color: var(--text);
    width: 100%;
    font-family: inherit;
}
.q-label:focus {
    outline: none;
    border-bottom-color: var(--theme);
}
.q-label::placeholder { color: #aaa; font-weight: 400; }

.q-type {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    background: #f8f9fa;
    color: var(--text);
    align-self: flex-start;
    cursor: pointer;
    max-width: 220px;
    font-family: inherit;
}
.q-type:focus { outline: none; border-color: var(--theme); }

.q-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0 0;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
}
.opt-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.opt-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    color: var(--text);
    min-width: 0;
    font-family: inherit;
}
.opt-input:focus {
    outline: none;
    border-color: var(--theme);
    box-shadow: 0 0 0 3px rgba(66,133,244,.12);
}
.q-options .btn.small { align-self: flex-start; margin-top: 6px; }

.q-required {
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
}
.q-required input {
    width: 16px; height: 16px;
    accent-color: var(--theme);
    cursor: pointer;
}
.q-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    padding-top: 4px;
}
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1;
    transition: all .15s;
    min-width: 32px;
    font-family: inherit;
}
.icon-btn:hover { background: #f1f3f4; color: var(--text); }
.icon-btn.danger:hover { background: #fce8e6; color: #c5221f; }

#addQuestion {
    width: 100%;
    padding: 18px;
    border: 2px dashed var(--border);
    background: #fff;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all .2s;
    margin-top: 8px;
    font-family: inherit;
}
#addQuestion:hover {
    border-color: var(--theme);
    color: var(--theme);
    background: #f8fbff;
}

.thankyou-editor {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}
.thankyou-editor h3 { font-size: 1rem; margin-bottom: 4px; }
.thankyou-editor input,
.thankyou-editor textarea {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    background: #fff;
    color: var(--text);
    width: 100%;
}
.thankyou-editor input:focus,
.thankyou-editor textarea:focus {
    outline: none;
    border-color: var(--theme);
    box-shadow: 0 0 0 3px rgba(66,133,244,.12);
}
.thankyou-editor textarea { min-height: 80px; resize: vertical; }

/* ============================================
   FORMULÁRIO PÚBLICO
   ============================================ */
.public-form {
    min-height: 100vh;
    padding: 40px 20px;
}
.public-wrapper {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ⚠️ IMPORTANTE: o <form> dentro do wrapper também precisa do flex */
.public-wrapper > form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-header-card {
    background: #fff;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-top: 8px solid var(--theme);
}
.form-header-card h1 { font-size: 1.7rem; margin-bottom: 8px; }
.form-header-card p { color: var(--muted); }

.public-question {
    background: #fff;
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.q-public-label { font-weight: 500; font-size: 0.95rem; }
.req { color: #d93025; margin-left: 4px; }

.public-question input[type="text"],
.public-question input[type="email"],
.public-question input[type="number"],
.public-question textarea,
.public-question select {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    width: 100%;
    background: #fff;
}
.public-question input[type="text"]:focus,
.public-question input[type="email"]:focus,
.public-question input[type="number"]:focus,
.public-question textarea:focus,
.public-question select:focus {
    outline: none;
    border-color: var(--theme);
    box-shadow: 0 0 0 3px rgba(66,133,244,.15);
}

.opt-public {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}
.opt-public:hover { background: #f1f3f4; }
.opt-public input {
    width: 18px; height: 18px;
    accent-color: var(--theme);
    cursor: pointer;
    flex-shrink: 0;
}
.opt-public span {
    font-size: 0.95rem;
    color: var(--text);
}

.public-wrapper > form > .btn.primary {
    margin-top: 8px;
}

.thankyou-card {
    background: #fff;
    padding: 48px 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 8px solid var(--theme);
}
.check-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--theme);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem;
    margin: 0 auto 20px;
}
.thankyou-card h1 { font-size: 1.6rem; margin-bottom: 10px; }
.thankyou-card p { color: var(--muted); margin-bottom: 24px; }
.powered { text-align: center; color: var(--muted); font-size: 0.82rem; margin-top: 12px; }

/* ============================================
   DASHBOARD DE RESPOSTAS
   ============================================ */
.chart-card {
    background: #fff;
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.chart-card h3 { font-size: 1.05rem; margin-bottom: 16px; }
.chart-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: center;
}
.chart-canvas-wrap { position: relative; height: 260px; }
.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 260px;
    overflow-y: auto;
}
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.legend-row .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-label { flex: 1; }
.legend-count { color: var(--muted); font-size: 0.82rem; }

.text-answers { list-style: none; }
.text-answers li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.text-answers li:last-child { border-bottom: none; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    font-weight: 600;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

/* ============================================
   RESPONSIVO
   ============================================ */
@media (max-width: 900px) {
    .editor-layout { grid-template-columns: 1fr; gap: 18px; }
    .editor-sidebar { position: static; }
    .question-card { padding: 16px; gap: 10px; }
    .q-actions { flex-direction: row; gap: 2px; }
    .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .container { padding: 20px 14px; }
    .admin-header { padding: 12px 16px; }
    .page-header h1 { font-size: 1.4rem; }
    .form-header-card { padding: 22px; }
    .public-question { padding: 18px; }
}

/* ============================================
   LOGIN MELHORADO
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

/* Bolhas decorativas no fundo */
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    pointer-events: none;
}
.login-page::before {
    width: 400px; height: 400px;
    top: -100px; right: -100px;
    animation: float 8s ease-in-out infinite;
}
.login-page::after {
    width: 300px; height: 300px;
    bottom: -80px; left: -80px;
    animation: float 10s ease-in-out infinite reverse;
}
@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.05); }
}

.login-card {
    background: #fff;
    padding: 44px 40px;
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, .3);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: slideUp .5s ease-out;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-card .logo {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 22px;
    display: inline-block;
}
.login-card h1 {
    font-size: 1.65rem;
    margin-bottom: 6px;
    color: #202124;
}
.login-card p {
    color: #5f6368;
    margin-bottom: 26px;
    font-size: 0.92rem;
}
.login-card label {
    display: block;
    font-size: 0.83rem;
    font-weight: 600;
    color: #3c4043;
    margin: 16px 0 6px;
    letter-spacing: 0.2px;
}

/* Inputs com ícone */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}
.input-group .input-icon {
    position: absolute;
    left: 14px;
    font-size: 1rem;
    opacity: .6;
    pointer-events: none;
    z-index: 1;
}
.login-card .input-group input {
    width: 100%;
    padding: 13px 44px 13px 42px;
    border: 1.5px solid #e0e3e7;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #202124;
    background: #fafbfc;
    transition: all .2s;
}
.login-card .input-group input::placeholder {
    color: #9aa0a6;
}
.login-card .input-group input:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, .15);
}

/* Botão do olho */
.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
     transform: translateY(calc(-50% - 20px));   /* ⬅ sobe 3px */
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: #5f6368;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    line-height: 0;
}
.toggle-password:hover {
    background: #f1f3f4;
    color: #667eea;
}

    .toggle-password:active {
    transform: translateY(calc(-50% - 20px)) scale(.9);
}
/* Botão principal */
.login-card .btn.primary {
    margin-top: 24px;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 10px;
    transition: all .25s;
    position: relative;
    overflow: hidden;
}
.login-card .btn.primary:hover:not(:disabled) {
    filter: none;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, .4);
}
.login-card .btn.primary:disabled {
    opacity: .7;
    cursor: wait;
    transform: none;
}

/* Alerta de erro */
.login-card .alert.error {
    background: #fce8e6;
    color: #c5221f;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 0.88rem;
    border-left: 4px solid #c5221f;
    animation: shake .4s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

.hint {
    text-align: center;
    margin-top: 20px;
    font-size: 0.82rem;
    color: #5f6368;
    padding-top: 18px;
    border-top: 1px solid #f1f3f4;
}
.hint b {
    color: #667eea;
    background: #f0f4ff;
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Responsivo */
@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
        border-radius: 16px;
    }
    .login-card h1 { font-size: 1.4rem; }
}