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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.hidden {
    display: none !important;
}

/* Login Page */
#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
}

/* Admin Page */
#adminPage {
    min-height: 100vh;
    background: #f5f5f5;
}

header {
    background: white;
    padding: 20px 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #667eea;
    font-size: 24px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

#userInfo {
    color: #666;
}

/* Tabs */
.tabs {
    background: white;
    padding: 0 40px;
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 15px 30px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

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

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

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

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-header h2 {
    color: #333;
}

/* Forms Grid */
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.form-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.form-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.form-card h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.form-card .form-meta {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.form-card .form-url {
    background: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    margin-bottom: 15px;
}

.form-card .form-actions {
    display: flex;
    gap: 10px;
}

/* Responses List */
.responses-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.response-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.response-card:hover {
    transform: translateX(5px);
}

.response-card h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.response-card .response-meta {
    color: #666;
    font-size: 14px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    background: #5568d3;
}

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

.btn-secondary:hover {
    background: #5a6268;
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

/* Field Editor */
.field-editor {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
    position: relative;
}

.field-editor:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.field-editor.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.field-editor.drag-over {
    border-color: #667eea;
    border-style: dashed;
    background: #f0f4ff;
}

.field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.field-drag-handle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: move;
    flex: 1;
}

.field-drag-handle:hover .drag-icon {
    color: #667eea;
}

.drag-icon {
    font-size: 18px;
    color: #999;
    transition: color 0.2s;
    user-select: none;
}

.field-header h4 {
    color: #667eea;
    margin: 0;
    font-size: 16px;
}

.field-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

.field-move-buttons {
    display: flex;
    gap: 3px;
    margin-right: 5px;
}

.field-move-buttons button {
    min-width: 30px;
    padding: 5px 8px;
}

/* Editor de Texto Rico */
.rich-text-toolbar {
    display: flex;
    gap: 5px;
    padding: 8px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    flex-wrap: wrap;
}

.toolbar-btn {
    padding: 5px 10px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #e0e0e0;
}

.toolbar-btn:active {
    background: #d0d0d0;
}

.rich-text-editor {
    min-height: 200px;
    max-height: 400px;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 0 0 4px 4px;
    background: white;
    overflow-y: auto;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
}

.rich-text-editor:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.rich-text-editor h3 {
    color: #007bff;
    font-size: 16px;
    font-weight: bold;
    margin: 15px 0 10px 0;
}

.rich-text-editor p {
    margin: 8px 0;
}

.rich-text-editor ol,
.rich-text-editor ul {
    margin: 10px 0;
    padding-left: 25px;
}

.rich-text-editor li {
    margin: 5px 0;
}

/* Quill Editor Custom Styles */
[id^="quillEditor_"] {
    min-height: 300px;
}

.ql-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
}

.ql-editor {
    min-height: 300px;
}

.ql-editor.show-characters {
    font-family: 'Courier New', monospace;
}

.ql-show-characters {
    width: 28px;
    height: 24px;
    display: inline-block;
    border: 1px solid #ccc;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 5px;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
}

.ql-show-characters:hover {
    background: #e0e0e0;
}

.ql-show-characters:hover {
    background: #e0e0e0;
}

.ql-show-characters.active {
    background-color: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
}

/* Estilo para quebra de página no editor */
.ql-editor .pdf-page-break {
    page-break-after: always;
    border-top: 2px dashed #ccc;
    margin: 10px 0;
    padding: 5px 0;
    text-align: center;
    color: #999;
    font-size: 10px;
    background-color: #f9f9f9;
    display: block;
}

/* Botão de quebra de página na toolbar */
.ql-page-break {
    width: 28px !important;
    height: 24px !important;
}

/* Ajustar toolbar do Quill */
.ql-toolbar {
    border: 1px solid #ddd;
    border-radius: 4px 4px 0 0;
    background: #fafafa;
}

.ql-container {
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

/* Estilos para caracteres especiais no Quill */
.ql-editor.show-characters .char-space {
    color: #999;
    background-color: #f0f0f0;
    padding: 0 1px;
}

.field-options {
    margin-top: 10px;
}

.option-item {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    align-items: center;
}

.option-item input {
    flex: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

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

.modal-content.large {
    max-width: 95vw;
}

.modal-content.modal-large {
    max-width: 95vw;
    max-height: 95vh;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #667eea;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

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

/* Error Message */
.error-message {
    color: #dc3545;
    margin-top: 10px;
    font-size: 14px;
}

.success-message {
    color: #28a745;
    margin-top: 10px;
    font-size: 14px;
}

/* Response Details */
.response-detail-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

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

.response-detail-item h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.response-detail-item p {
    color: #666;
    line-height: 1.6;
}

.response-signature img,
.response-photo img {
    max-width: 100%;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 10px;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

/* Scrollbar personalizada para modal */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Melhorias no container de campos */
#fieldsContainer {
    min-height: 200px;
    padding: 10px 0;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

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

    .tabs {
        padding: 0 20px;
    }

    .tab-content {
        padding: 20px;
    }
    
    .modal-content {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-body {
        padding: 20px;
    }
}
