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

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #1a202c;
    padding: 1.5rem 2rem;
    text-align: center;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

/* Main content */
main {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Form sections */
.form-section {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: rgba(248, 250, 252, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.form-section:last-of-type {
    margin-bottom: 1rem;
}

.form-section h2 {
    color: #1e293b;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

/* Form groups */
.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: #374151;
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.625rem 0.75rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: white;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

/* Template section special styling */
.template-section {
    background: rgba(255, 255, 255, 0.7);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-top: 0;
}

.template-section .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.quick-suggestion {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 0.75rem;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

.dynamic-form-section {
    background: rgba(248, 250, 252, 0.7);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.dynamic-form-section h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #1e293b;
    font-size: 1.125rem;
    font-weight: 600;
}

.field-info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-left: 3px solid #667eea;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
}

.field-info p {
    margin: 0;
    font-size: 0.8125rem;
    color: #475569;
    line-height: 1.4;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.1);
    color: #475569;
    border: 1.5px solid rgba(148, 163, 184, 0.3);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.5);
    transform: translateY(-1px);
}

#suggestTemplate {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

#suggestTemplate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(245, 87, 108, 0.4);
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    flex-wrap: wrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success message */
.success-message {
    background-color: #2ecc71;
    color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
    animation: slideIn 0.3s ease-out;
}

/* Error message */
.error-message {
    background-color: #e74c3c;
    color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
    animation: slideIn 0.3s ease-out;
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }
    
    header {
        padding: 1rem 1.5rem;
        margin-bottom: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 0.8125rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .form-section {
        padding: 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 0.75rem;
    }
    
    .suggestion-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .upload-container {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    header,
    footer {
        display: none;
    }
    
    main {
        box-shadow: none;
        padding: 0;
    }
}

/* Accessibility improvements */
input[required] + label::after,
select[required] + label::after {
    content: " *";
    color: #e74c3c;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Disabled state */
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Tooltips */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.modal-header h2 {
    margin: 0;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: rgba(148, 163, 184, 0.1);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(148, 163, 184, 0.2);
    color: #475569;
    transform: scale(1.05);
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
}

/* Field Customization Styles */
.field-customization-item {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.field-customization-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.field-tag {
    font-family: monospace;
    background-color: #e8f4f8;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #2c3e50;
}

.field-customization-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.field-customization-controls .form-group {
    margin-bottom: 0.5rem;
}

.field-customization-controls label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.field-customization-controls input,
.field-customization-controls select {
    font-size: 0.9rem;
    padding: 0.5rem;
}

.field-preview {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    margin-top: 1rem;
}

.field-preview label {
    font-weight: 600;
    color: #333;
}

.field-preview-title {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Template Upload Styles */
.upload-section {
    background: rgba(255, 255, 255, 0.9);
    border: 2px dashed rgba(102, 126, 234, 0.4);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.upload-section:hover {
    border-color: rgba(102, 126, 234, 0.6);
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-1px);
}

.upload-section h3 {
    margin-top: 0;
    margin-bottom: 0.375rem;
    color: #1e293b;
    font-size: 1rem;
    font-weight: 600;
}

.upload-section p {
    margin-bottom: 0.75rem;
    color: #64748b;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.upload-container {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
}

.upload-container .form-group {
    flex: 1;
    min-width: 200px;
}

.file-hint {
    display: block;
    margin-top: 0.25rem;
    color: #94a3b8;
    font-size: 0.75rem;
}

/* File Input Styling */
input[type="file"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    background-color: #fff;
    font-size: 0.9rem;
    transition: border-color 0.3s;
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: #3498db;
}

input[type="file"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Upload Progress Bar */
.upload-progress {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background-color: #3498db;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

/* Section Divider */
.section-divider {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
    text-align: center;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(226, 232, 240, 0.6);
}

.section-divider span {
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    color: #64748b;
    font-weight: 500;
    font-size: 0.8125rem;
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    backdrop-filter: blur(10px);
}

/* Existing Templates Section */
.existing-templates {
    background: rgba(255, 255, 255, 0.9);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.6);
}

.existing-templates h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #1e293b;
    font-size: 1rem;
    font-weight: 600;
}

/* Responsive Design for Upload */
@media (max-width: 768px) {
    .upload-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .upload-container .form-group {
        min-width: auto;
    }
    
    .upload-container button {
        margin-top: 0.5rem;
    }
}

/* Template Value Indicators */
.template-value {
    background-color: #f0f8ff !important;
    border-color: #3498db !important;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1) !important;
}

.template-value:focus {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2) !important;
}

/* Template indicator styles removed - no longer using icons */

/* Template value info section */
.template-info {
    background-color: #e8f4f8;
    border-left: 4px solid #3498db;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.template-info .info-header {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-info .info-content {
    color: #34495e;
    font-size: 0.9rem;
}

.template-info .info-content ul {
    margin: 0.5rem 0 0 1rem;
    padding: 0;
}

.template-info .info-content li {
    margin-bottom: 0.25rem;
}

/* Authentication Styles */
.auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #1a202c;
    font-weight: 600;
}

.google-auth {
    text-align: center;
    padding: 20px;
}

.google-auth h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 24px;
}

.google-auth p {
    margin-bottom: 30px;
    color: #666;
    font-size: 16px;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 6px;
    color: #3c4043;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.btn-google:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form button {
    width: 100%;
    margin-top: 0.5rem;
}

.auth-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-size: 0.875rem;
    display: none;
}

.auth-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
    display: block;
}

.auth-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: block;
}

/* Header with user menu */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.header-left h1 {
    margin-bottom: 0.25rem;
}

.header-left p {
    margin: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

/* Documents Management Styles */
.documents-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.documents-section h2 {
    color: #1e293b;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.documents-list {
    display: grid;
    gap: 1rem;
}

.document-item {
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.document-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.document-title {
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    font-size: 1rem;
}

.document-actions {
    display: flex;
    gap: 0.5rem;
}

.document-actions button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

.document-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.document-description {
    color: #475569;
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0;
}

.documents-empty {
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

.documents-empty h3 {
    margin-bottom: 0.5rem;
    color: #94a3b8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .user-menu {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .document-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .document-actions {
        align-self: stretch;
    }
    
    .document-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .auth-section {
        padding: 1rem;
    }
    
    .auth-container {
        padding: 1.5rem;
    }
}