/* FieldForms Lite - Custom Styles */

:root {
    --primary-color: #2563eb;
    --secondary-color: #f3f4f6;
    --text-color: #111827;
    --background-color: #ffffff;
    --border-color: #e5e7eb;
    --card-background: #ffffff;
    --sidebar-background: #ffffff;
    --nav-background: #2563eb;
    --input-background: #ffffff;
    --modal-background: rgba(0, 0, 0, 0.5);
}

/* Dark Mode */
body.dark-mode {
    --primary-color: #3b82f6;
    --secondary-color: #1f2937;
    --text-color: #f9fafb;
    --background-color: #111827;
    --border-color: #374151;
    --card-background: #1f2937;
    --sidebar-background: #1f2937;
    --nav-background: #1f2937;
    --input-background: #374151;
    --modal-background: rgba(0, 0, 0, 0.8);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color) !important;
    color: var(--text-color) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Override Tailwind background classes for dark mode */
body.dark-mode * {
    border-color: var(--border-color);
}

body.dark-mode .bg-white {
    background-color: var(--card-background) !important;
}

body.dark-mode .bg-gray-50 {
    background-color: var(--background-color) !important;
}

body.dark-mode .bg-gray-100 {
    background-color: var(--secondary-color) !important;
}

body.dark-mode .text-gray-900 {
    color: var(--text-color) !important;
}

body.dark-mode .text-gray-800 {
    color: var(--text-color) !important;
}

body.dark-mode .text-gray-700 {
    color: #d1d5db !important;
}

body.dark-mode .text-gray-600 {
    color: #9ca3af !important;
}

body.dark-mode .text-gray-500 {
    color: #6b7280 !important;
}

body.dark-mode .border-gray-200 {
    border-color: var(--border-color) !important;
}

body.dark-mode .border-gray-300 {
    border-color: var(--border-color) !important;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: var(--input-background) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .shadow-lg,
body.dark-mode .shadow-xl {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3) !important;
}

/* Navigation Active State */
.nav-btn {
    transition: all 0.2s ease;
}

.nav-btn.active {
    background-color: #dbeafe;
    color: var(--primary-color);
}

body.dark-mode .nav-btn.active {
    background-color: #1e3a8a;
    color: #60a5fa;
}

.nav-btn:hover:not(.active) {
    background-color: #f9fafb;
}

body.dark-mode .nav-btn:hover:not(.active) {
    background-color: #374151;
}

/* View Transitions */
.view-content {
    animation: fadeIn 0.3s ease-in;
}

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

/* Field Card Styles */
.field-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
    cursor: move;
}

.field-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.field-card.dragging {
    opacity: 0.5;
}

/* Form Card Styles */
.form-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.form-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

/* Submission Card Styles */
.submission-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.submission-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

/* Signature Pad Styles */
.signature-canvas {
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
    cursor: crosshair;
    background: var(--input-background);
}

.signature-canvas:hover {
    border-color: var(--primary-color);
}

/* Image Upload Preview */
.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}

/* Drag and Drop States */
.drag-over {
    background-color: #eff6ff;
    border-color: var(--primary-color);
}

body.dark-mode .drag-over {
    background-color: #1e3a8a;
    border-color: var(--primary-color);
}

/* File Input Custom */
input[type="file"] {
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
    background-color: #1d4ed8;
}

/* Modal Animations */
.modal-enter {
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--secondary-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
}

body.dark-mode .empty-state {
    color: #9ca3af;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

body.dark-mode .badge-blue {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.badge-green {
    background-color: #d1fae5;
    color: #065f46;
}

body.dark-mode .badge-green {
    background-color: #064e3b;
    color: #6ee7b7;
}

.badge-gray {
    background-color: #f3f4f6;
    color: #374151;
}

body.dark-mode .badge-gray {
    background-color: #374151;
    color: #d1d5db;
}

.badge-red {
    background-color: #fee2e2;
    color: #991b1b;
}

body.dark-mode .badge-red {
    background-color: #7f1d1d;
    color: #fca5a5;
}

/* Required Field Indicator */
.required::after {
    content: '*';
    color: #dc2626;
    margin-left: 0.25rem;
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    background-color: #1f2937;
    color: white;
    text-align: center;
    border-radius: 0.375rem;
    padding: 0.5rem;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.875rem;
    white-space: nowrap;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s ease;
}

.dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 39;
}

.mobile-overlay.active {
    display: block;
}

/* Responsive Utilities */
@media (max-width: 1024px) {
    aside {
        width: 200px;
    }
}

@media (max-width: 768px) {
    aside {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 40;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    aside.open {
        left: 0;
    }

    main {
        padding: 0.75rem;
        width: 100%;
    }

    /* Make form editor responsive */
    #formEditor .grid {
        grid-template-columns: 1fr !important;
    }

    /* Stack buttons vertically on small screens */
    .flex.space-x-2,
    .flex.space-x-4 {
        flex-direction: column;
        gap: 0.5rem;
    }

    .flex.space-x-2 > *,
    .flex.space-x-4 > * {
        width: 100%;
        margin: 0;
    }

    /* Adjust card padding */
    .form-card,
    .submission-card,
    .field-card {
        padding: 1rem;
    }

    /* Make modals full screen on mobile */
    .fixed.inset-0 > div {
        max-width: 95% !important;
        margin: 1rem;
    }

    /* Adjust font sizes */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    main {
        padding: 0.5rem;
    }

    .form-card,
    .submission-card {
        padding: 0.75rem;
    }

    /* Stack navigation items */
    nav .flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Full width buttons */
    button {
        width: 100%;
        justify-content: center;
    }

    /* Reduce text size */
    body {
        font-size: 14px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-color);
}

::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Focus Visible Enhancement */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Transitions for smooth interactions */
button, a, input, select, textarea {
    transition: all 0.2s ease;
}

/* Form Input Enhancements */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Error States */
.error {
    border-color: #dc2626 !important;
}

.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Success States */
.success {
    border-color: #059669 !important;
}

.success-message {
    color: #059669;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}
