/* css/style.css */

/* ========== RESET & BASE ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2E7D32;
    --primary-light: #4CAF50;
    --primary-dark: #1B5E20;
    --secondary: #FF6F00;
    --secondary-light: #FFA726;
    --bg: #F5F5F5;
    --card-bg: #FFFFFF;
    --text: #212121;
    --text-light: #757575;
    --text-white: #FFFFFF;
    --border: #E0E0E0;
    --success: #2E7D32;
    --error: #D32F2F;
    --warning: #F57F17;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html {
    font-size: 18px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========== LAYOUT ========== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 100px;
}

/* ========== HEADER ========== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-white);
    padding: 20px 16px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.header .subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 4px;
}

/* ========== CARDS ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== DICAS / HELP ========== */
.help-tip {
    background: #E8F5E9;
    border-left: 4px solid var(--primary);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.help-tip .icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.help-banner {
    background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
    border: 1px solid #FFB74D;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.help-banner .title {
    font-weight: 700;
    color: var(--secondary);
    font-size: 1rem;
    margin-bottom: 4px;
}

.help-banner .desc {
    font-size: 0.8rem;
    color: #E65100;
}

/* ========== FORMULÁRIOS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.95rem;
}

.form-label .required {
    color: var(--error);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
}

.form-input::placeholder {
    color: #BDBDBD;
}

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

/* ========== BOTÕES ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    min-height: 52px;
    width: 100%;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-white);
    box-shadow: 0 3px 10px rgba(46, 125, 50, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.4);
}

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

.btn-secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: #E8F5E9;
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary), #E65100);
    color: var(--text-white);
    box-shadow: 0 3px 10px rgba(255, 111, 0, 0.3);
}

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

.btn-sm {
    padding: 10px 16px;
    font-size: 0.85rem;
    min-height: 42px;
    width: auto;
}

.btn-copy {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
    color: var(--text-white);
    box-shadow: 0 3px 10px rgba(21, 101, 192, 0.3);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-group .btn {
    flex: 1;
    min-width: 120px;
}

/* ========== OPÇÕES DINÂMICAS ========== */
.opcoes-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.opcao-item {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

.opcao-item .form-input {
    flex: 1;
}

.btn-remove-opcao {
    background: var(--error);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: var(--radius-sm);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    padding: 0;
}

.btn-add-opcao {
    background: #E8F5E9;
    color: var(--primary);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    font-family: var(--font);
    min-height: 48px;
}

.btn-add-opcao:hover {
    background: #C8E6C9;
}

/* ========== PERGUNTA CARD (nos forms de resposta) ========== */
.pergunta-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}

.pergunta-titulo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.pergunta-obrigatoria {
    color: var(--error);
    font-size: 0.8rem;
    margin-bottom: 12px;
}

/* ========== OPÇÕES DE RESPOSTA (Estilo WhatsApp) ========== */
.opcao-resposta {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.opcao-resposta:hover {
    border-color: var(--primary-light);
    background: #F1F8E9;
}

.opcao-resposta.selecionada {
    border-color: var(--primary);
    background: #E8F5E9;
}

.opcao-resposta input[type="radio"] {
    display: none;
}

.opcao-check {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.opcao-resposta.selecionada .opcao-check {
    border-color: var(--primary);
    background: var(--primary);
}

.opcao-resposta.selecionada .opcao-check::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.opcao-texto {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
}

.opcao-votos {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Barra de progresso dos votos */
.opcao-barra {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--primary-light);
    transition: width 0.5s ease;
    border-radius: 0 2px 2px 0;
}

/* ========== RESULTADOS ========== */
.resultado-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.resultado-pergunta {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.resultado-opcao {
    margin-bottom: 12px;
}

.resultado-opcao-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.resultado-opcao-texto {
    font-weight: 600;
    font-size: 0.95rem;
}

.resultado-opcao-count {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}

.resultado-barra-bg {
    width: 100%;
    height: 28px;
    background: #E8F5E9;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.resultado-barra-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 14px;
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    min-width: 0;
}

.resultado-barra-percent {
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Detalhes - nomes */
.resultado-nomes {
    margin-top: 8px;
    padding: 10px;
    background: #FAFAFA;
    border-radius: var(--radius-sm);
    display: none;
}

.resultado-nomes.show {
    display: block;
}

.resultado-nomes .nome-tag {
    display: inline-block;
    background: #E8F5E9;
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin: 3px;
    font-weight: 500;
}

.btn-ver-nomes {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
    padding: 4px 0;
    font-family: var(--font);
    text-decoration: underline;
}

/* ========== TOTAL DE RESPOSTAS ========== */
.total-respostas {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-white);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
}

.total-respostas .numero {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.total-respostas .label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 4px;
}

/* ========== LINK COMPARTILHAR ========== */
.link-container {
    background: #E3F2FD;
    border: 2px solid #90CAF9;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    text-align: center;
}

.link-container .link-label {
    font-size: 0.85rem;
    color: #1565C0;
    font-weight: 600;
    margin-bottom: 8px;
}

.link-url {
    background: white;
    border: 1px solid #BBDEFB;
    border-radius: var(--radius-sm);
    padding: 12px;
    word-break: break-all;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 12px;
    font-family: monospace;
}

/* ========== LISTA DE QUESTIONÁRIOS ========== */
.questionario-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.questionario-item .q-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.questionario-item .q-data {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.questionario-item .q-titulo {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-dark);
}

.questionario-item .q-respostas {
    font-size: 0.85rem;
    color: var(--text-light);
}

.q-badge {
    background: var(--primary);
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.q-badge.inativo {
    background: #9E9E9E;
}

.q-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
}

.tab.active {
    background: var(--primary);
    color: var(--text-white);
    box-shadow: 0 2px 6px rgba(46, 125, 50, 0.3);
}

/* ========== TOAST / NOTIFICAÇÃO ========== */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    width: calc(100% - 32px);
    max-width: 400px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.info {
    background: #1565C0;
}

/* ========== LOADING ========== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-light);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.modal-text {
    color: var(--text-light);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state .title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state .desc {
    font-size: 0.85rem;
}

/* ========== ANIMAÇÕES ========== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

/* ========== RESPONSIVO ========== */
@media (max-width: 380px) {
    html {
        font-size: 16px;
    }

    .container {
        padding: 12px;
    }

    .card {
        padding: 16px;
    }

    .btn {
        padding: 12px 18px;
        min-height: 48px;
    }
}

/* ========== LISTA DETALHADA ========== */
.lista-detalhada {
    margin-top: 16px;
}

.resposta-pessoa {
    background: #FAFAFA;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
}

.resposta-pessoa-nome {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.resposta-pessoa-item {
    font-size: 0.85rem;
    color: var(--text);
    padding: 3px 0;
}

.resposta-pessoa-item strong {
    color: var(--text-light);
}

/* ========== NAVEGAÇÃO INFERIOR ========== */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    padding: 8px 16px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.nav-bottom a {
    flex: 1;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

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

.nav-bottom a .nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

/* Sucesso após envio */
.success-animation {
    text-align: center;
    padding: 40px 20px;
}

.success-animation .checkmark {
    font-size: 4rem;
    animation: bounceIn 0.5s ease;
}

.success-animation .msg {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 12px;
}

.success-animation .submsg {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 8px;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Perguntas adicionais container */
.perguntas-extras {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pergunta-extra-item {
    background: #F5F5F5;
    border-radius: var(--radius-sm);
    padding: 16px;
    position: relative;
    border: 1px solid var(--border);
}

.pergunta-extra-item .pergunta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pergunta-extra-item .pergunta-numero {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
}

/* Auto refresh indicator */
.auto-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-light);
    padding: 8px;
}

.auto-refresh .dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}