/* CSS Variables - Green Chambers Theme */
:root {
    --primary: #1B4D3E;
    --primary-dark: #143830;
    --primary-light: #2d6b5a;
    --accent: #10b981;
    --accent-light: #34d399;
    --background: #f8faf9;
    --surface: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-dark: #d1d5db;
    --error: #ef4444;
    --error-light: #fee2e2;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3 {
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--border-dark);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--background);
    color: var(--text);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 77, 62, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--background);
}

/* Auth Modal */
.auth-modal {
    padding: 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-header h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-light);
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-form {
    display: none;
}

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

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

.user-info span {
    font-size: 0.875rem;
    opacity: 0.9;
}

.user-info .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.user-info .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Progress Steps */
.progress-container {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
}

.progress-steps {
    display: flex;
    justify-content: center;
    gap: 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.progress-step.active .step-number,
.progress-step.completed .step-number {
    background: var(--primary);
    color: white;
}

.step-label {
    font-size: 0.8125rem;
    color: var(--text-light);
    font-weight: 500;
}

.progress-step.active .step-label {
    color: var(--primary);
}

/* Main Content */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.step {
    display: none;
    opacity: 1;
}

.step.active {
    display: block;
    opacity: 1;
}

.step-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.step-content h2 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.step-description {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.step-header h2 {
    margin-bottom: 0;
}

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

.step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--background);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(27, 77, 62, 0.02);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(27, 77, 62, 0.05);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--success-light);
    border-radius: var(--radius);
    margin-top: 1rem;
}

.file-info.hidden {
    display: none;
}

.file-icon {
    color: var(--success);
}

.file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    color: var(--text);
}

.file-size {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Templates Section */
.templates-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.templates-section h3 {
    margin-bottom: 0.5rem;
}

.templates-hint {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.template-card {
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.template-card:hover {
    border-color: var(--primary);
    background: rgba(27, 77, 62, 0.02);
}

.template-name {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.template-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Field Filters */
.field-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8125rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Field Search */
.field-search {
    margin-bottom: 1.5rem;
}

.field-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
}

.field-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 77, 62, 0.1);
}

/* Fields Container */
.fields-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--background);
}

.field-item {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.field-item:last-child {
    margin-bottom: 0;
}

.field-item.hidden {
    display: none;
}

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

.field-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
    font-family: 'Monaco', 'Consolas', monospace;
}

.field-type {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--background);
    border-radius: 4px;
    color: var(--text-light);
    text-transform: uppercase;
}

.field-input input,
.field-input textarea,
.field-input select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.field-input textarea {
    min-height: 80px;
    resize: vertical;
}

.field-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.field-checkbox label {
    font-size: 0.875rem;
    color: var(--text);
}

/* Signature Section */
.signature-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.signature-section h3 {
    margin-bottom: 1rem;
}

.signature-options {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--radius);
}

.signature-fields {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.signature-fields.hidden {
    display: none;
}

.signature-upload {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.signature-preview {
    max-width: 200px;
    padding: 0.5rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.signature-preview.hidden {
    display: none;
}

.signature-preview img {
    max-width: 100%;
    height: auto;
}

/* Summary Section */
.summary-section {
    margin-bottom: 2rem;
}

.summary-section h3 {
    margin-bottom: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.summary-item {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.summary-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

/* Preview Section */
.preview-section {
    margin-bottom: 2rem;
}

.preview-section h3 {
    margin-bottom: 1rem;
}

.filled-fields-preview {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
}

.preview-field {
    display: flex;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.preview-field:last-child {
    border-bottom: none;
}

.preview-field-name {
    flex: 0 0 40%;
    font-size: 0.8125rem;
    font-family: 'Monaco', 'Consolas', monospace;
    color: var(--text-light);
}

.preview-field-value {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text);
    word-break: break-word;
}

/* Download Section */
.download-section {
    margin-bottom: 1.5rem;
}

.download-section h3 {
    margin-bottom: 1rem;
}

.download-options {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--radius);
}

.download-option {
    margin-bottom: 1rem;
}

.download-option:last-child {
    margin-bottom: 0;
}

.download-option label:not(.checkbox-label) {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.download-option input[type="text"] {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .progress-steps {
        gap: 1rem;
    }

    .step-label {
        display: none;
    }

    .step-content {
        padding: 1.5rem;
    }

    .field-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .step-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .step-actions .btn {
        width: 100%;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
