/* WorkflowHub Custom Styles */

/* Fix main wrapper layout */
#main-wrapper {
    display: flex;
    min-height: 100vh;
    background: linear-gradient(135deg, #0A3D72 0%, #012D5A 100%);
}

/* Header styling */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar styling */
.navbar-vertical {
    position: fixed;
    top: 0;
    left: 0;
    width: 16.25rem;
    height: 100vh;
    z-index: 1020;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    transition: margin-left 0.3s ease-in-out;
}

/* App content area */
#app-content {
    flex: 1;
    margin-left: 16.25rem;
    margin-top: 70px; /* Account for fixed header */
    min-height: calc(100vh - 70px);
    transition: margin-left 0.3s ease-in-out;
    padding: 2rem;
}

/* Page wrapper */
.page-wrapper {
    min-height: 100%;
}

/* Page content */
.page-content {
    color: white;
}

/* Card styling */
.card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-body {
    color: white;
}

/* Navigation toggle states */
#main-wrapper.toggled .navbar-vertical {
    margin-left: -16.25rem;
}

#main-wrapper.toggled #app-content {
    margin-left: 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .navbar-vertical {
        margin-left: -16.25rem;
    }
    
    #app-content {
        margin-left: 0;
    }
    
    #main-wrapper.toggled .navbar-vertical {
        margin-left: 0;
    }
    
    #main-wrapper.toggled #app-content {
        margin-left: 16.25rem;
    }
}

/* Text colors for better visibility */
.text-white {
    color: white !important;
}

.text-white-50 {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Button styling */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
}

/* Avatar styling */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
}

.avatar-md {
    width: 3rem;
    height: 3rem;
}

.avatar-lg {
    width: 4rem;
    height: 4rem;
}

.avatar-xl {
    width: 5rem;
    height: 5rem;
}

/* Badge styling */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
}

/* Form controls */
.form-control, .form-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.form-control:focus, .form-select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Dropdown styling */
.dropdown-menu {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-item {
    color: white;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Alert styling */
.alert {
    border: none;
    border-radius: 0.5rem;
}

/* Table styling */
.table {
    color: white;
}

.table th,
.table td {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Modal styling */
.modal-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-header,
.modal-footer {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.app-content-area, .container-fluid {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* SweetAlert2 Custom Styles for Dark Theme */
.swal2-popup {
    background: #0A3D72 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

.swal2-title {
    color: #ffffff !important;
    font-weight: 600 !important;
}

.swal2-content {
    color: #ffffff !important;
}

.swal2-icon {
    border-color: #ffffff !important;
}

.swal2-icon.swal2-error {
    border-color: #dc3545 !important;
}

.swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
    background-color: #dc3545 !important;
}

.swal2-icon.swal2-success {
    border-color: #28a745 !important;
}

.swal2-icon.swal2-success [class^='swal2-success-circular-line'] {
    background-color: #28a745 !important;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: #28a745 !important;
}

.swal2-icon.swal2-warning {
    border-color: #ffc107 !important;
}

.swal2-icon.swal2-warning [class^='swal2-warning-circular-line'] {
    background-color: #ffc107 !important;
}

.swal2-icon.swal2-info {
    border-color: #17a2b8 !important;
}

.swal2-icon.swal2-info [class^='swal2-info-circular-line'] {
    background-color: #17a2b8 !important;
}

.swal2-icon.swal2-question {
    border-color: #007bff !important;
}

.swal2-icon.swal2-question [class^='swal2-question-circular-line'] {
    background-color: #007bff !important;
}

.swal2-confirm {
    background: linear-gradient(90deg, #FFD000 0%, #FFB300 100%) !important;
    border: none !important;
    border-radius: 6px !important;
    color: #000000 !important;
    font-weight: 600 !important;
    padding: 10px 24px !important;
    transition: all 0.2s ease !important;
}

.swal2-confirm:hover {
    background: linear-gradient(90deg, #FFB300 0%, #FFD000 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(255, 208, 0, 0.3) !important;
}

.swal2-cancel {
    background: linear-gradient(90deg, #FFD000 0%, #FFB300 100%) !important;
    border: none !important;
    border-radius: 6px !important;
    color: #000000 !important;
    font-weight: 600 !important;
    padding: 10px 24px !important;
    transition: all 0.2s ease !important;
}

.swal2-cancel:hover {
    background: linear-gradient(90deg, #FFB300 0%, #FFD000 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(255, 208, 0, 0.3) !important;
}

.swal2-timer-progress-bar {
    background: #007bff !important;
}

.swal2-backdrop {
    background: rgba(0, 0, 0, 0.8) !important;
}

/* SweetAlert2 Form Controls - Fix white background issue */
.swal2-popup .form-control,
.swal2-popup .form-select {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.swal2-popup .form-control:focus,
.swal2-popup .form-select:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25) !important;
}

.swal2-popup .form-control::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Fix select dropdown options */
.swal2-popup .form-select option {
    background: #0A3D72 !important;
    color: white !important;
}

/* Fix form labels in SweetAlert */
.swal2-popup .form-label {
    color: white !important;
    font-weight: 500 !important;
    margin-bottom: 0.5rem !important;
}

/* Fix textarea in SweetAlert */
.swal2-popup textarea.form-control {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    resize: vertical !important;
}

.swal2-popup textarea.form-control:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25) !important;
}

/* Template Wizard Styles */
.wizard-step {
    animation: fadeIn 0.3s ease-in-out;
}

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

.template-type-card .card {
    transition: all 0.3s ease;
    border-width: 2px !important;
}

.template-type-card .card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.template-library-card .card {
    transition: all 0.3s ease;
    border-width: 2px !important;
}

.template-library-card .card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.placeholder-tag {
    transition: all 0.2s ease;
    color: #FFD000 !important;
}

.placeholder-tag:hover {
    background: rgba(255, 208, 0, 0.2) !important;
    transform: scale(1.05);
}

/* Enhanced Preview Modal Styles */
.modal-fullscreen .modal-body {
    padding: 0;
}

.preview-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 10px;
    overflow-x: scroll !important; /* Force horizontal scrollbar */
    overflow-y: auto !important;
    width: 100%;
    height: 100%;
    scrollbar-width: auto;
    scrollbar-color: #666 #e0e0e0;
}

/* Custom scrollbar styling for webkit browsers */
.preview-container::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

.preview-container::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 8px;
}

.preview-container::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.preview-container::-webkit-scrollbar-thumb:hover {
    background: #444;
}

.preview-container::-webkit-scrollbar-corner {
    background: #e0e0e0;
}

.preview-paper {
    transition: transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    background: white;
    border-radius: 8px;
    overflow: visible;
    position: relative;
    width: 1200px !important; /* Much wider to force horizontal scroll */
    min-width: 1200px !important;
    max-width: none;
    margin: 0;
    min-height: 600px;
    flex-shrink: 0;
}

/* Ensure the document preview fills the container properly */
#documentPreview {
    width: 1120px !important; /* Fixed width to match paper minus padding */
    min-width: 1120px !important; /* Ensure minimum width for content */
    max-width: none !important;
    overflow: visible !important;
    background: white !important;
    min-height: 600px;
    position: relative;
    padding: 40px !important;
    box-sizing: border-box;
    margin: 0 !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
}

/* Fix any layout issues with the preview content */
.preview-paper #documentPreview {
    padding: 40px !important;
    box-sizing: border-box;
}

/* Ensure proper text rendering */
#documentPreview * {
    box-sizing: border-box;
    max-width: 100%;
}

/* Fix header positioning - ensure it starts at the very top */
#documentPreview .header {
    margin-top: 0 !important;
    padding-top: 0 !important;
    position: relative;
    top: 0;
}

#documentPreview .header h1 {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ensure the first element in preview has no top margin */
#documentPreview > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Fix any Bootstrap or other CSS that might add top spacing */
#documentPreview > .header:first-child,
#documentPreview > div:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ensure document content uses full width */
#documentPreview h1 {
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    width: 100% !important;
}

#documentPreview .header h1 {
    font-size: 28px !important;
    line-height: 1.2 !important;
    margin: 0 0 20px 0 !important;
    letter-spacing: 2px !important;
}

/* Ensure all content fits within the container */
#documentPreview * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Restore original field label width for better document formatting */
#documentPreview .field-label {
    width: 250px !important;
    min-width: 250px !important;
}

#documentPreview table {
    width: 100% !important;
    min-width: 1000px !important;
    table-layout: fixed !important;
}

#documentPreview .field {
    width: 100% !important;
    min-width: 1000px !important;
}

/* Ensure sections maintain width */
#documentPreview .section {
    width: 100% !important;
    min-width: 1000px !important;
}

#documentPreview .header {
    width: 100% !important;
    min-width: 1000px !important;
}

.preview-input {
    transition: all 0.2s ease;
}

.preview-input:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25) !important;
}

/* Zoom controls styling */
.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.btn-group .btn:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* Preview status indicator */
#previewStatus {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Sample data cards */
.card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Auto-preview switch */
.form-check-input:checked {
    background-color: #198754;
    border-color: #198754;
}

/* Enhanced document preview styling */
#documentPreview {
    transition: all 0.3s ease;
}

#documentPreview:empty::before {
    content: "Preview will appear here...";
    color: #6c757d;
    font-style: italic;
    display: block;
    text-align: center;
    padding: 2rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-fullscreen .modal-body .row {
        flex-direction: column;
    }

    .modal-fullscreen .modal-body .col-md-4,
    .modal-fullscreen .modal-body .col-md-8 {
        max-width: 100%;
        flex: 0 0 100%;
    }

    .preview-paper {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
}

/* Fix input number controls */
.swal2-popup input[type="number"] {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.swal2-popup input[type="number"]:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25) !important;
}

/* Category headers in select dropdowns */
.swal2-popup .form-select option.category-header {
    background: #1a4d7a !important;
    color: #FFD000 !important;
    font-weight: bold !important;
    font-style: italic !important;
    text-align: center !important;
    border-top: 1px solid rgba(255, 208, 0, 0.5) !important;
    border-bottom: 1px solid rgba(255, 208, 0, 0.5) !important;
    margin: 2px 0 !important;
}

/* Category headers hover state */
.swal2-popup .form-select option.category-header:hover {
    background: #2a5d8a !important;
    color: #FFD000 !important;
}

/* Regular options styling */
.swal2-popup .form-select option:not(.category-header) {
    background: #0A3D72 !important;
    color: white !important;
    padding-left: 1.5rem !important;
}

/* Default/placeholder option styling */
.swal2-popup .form-select option[value=""]:not(.category-header) {
    background: rgba(255, 255, 255, 0.05) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-style: italic !important;
    padding-left: 1rem !important;
}

/* Hover effects for options */
.swal2-popup .form-select option:not(.category-header):hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

/* Focus state for select */
.swal2-popup .form-select:focus option.category-header {
    background: #1a4d7a !important;
    color: #FFD000 !important;
}

/* Additional browser-specific fixes for category headers */
.swal2-popup select option.category-header,
.swal2-popup select option[disabled].category-header {
    background-color: #1a4d7a !important;
    background: #1a4d7a !important;
    color: #FFD000 !important;
}

/* Webkit browsers specific fixes */
.swal2-popup select option.category-header:checked {
    background: #1a4d7a !important;
    color: #FFD000 !important;
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
    .swal2-popup .form-select option.category-header {
        background-color: #1a4d7a !important;
        color: #FFD000 !important;
    }
}

/* Ensure select dropdown has proper dark styling */
.swal2-popup .form-select {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

/* Force category header styling across all states */
.swal2-popup option[disabled].category-header,
.swal2-popup option.category-header[disabled],
.swal2-popup .form-select option.category-header {
    background: #1a4d7a !important;
    background-color: #1a4d7a !important;
    color: #FFD000 !important;
    font-weight: bold !important;
    font-style: italic !important;
    text-align: center !important;
}

/* Prevent white background on category headers in all browsers */
.swal2-popup .form-select option.category-header:not(:checked):not(:hover) {
    background: #1a4d7a !important;
    background-color: #1a4d7a !important;
    color: #FFD000 !important;
}

/* Document type checkboxes styling in SweetAlert */
.swal2-popup .form-check {
    margin-bottom: 0.5rem !important;
}

.swal2-popup .form-check-input {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    margin-top: 0.25rem !important;
}

.swal2-popup .form-check-input:checked {
    background-color: #FFD000 !important;
    border-color: #FFD000 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
}

.swal2-popup .form-check-input:focus {
    border-color: rgba(255, 208, 0, 0.5) !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 208, 0, 0.25) !important;
}

.swal2-popup .form-check-label {
    color: white !important;
    font-size: 0.9rem !important;
    margin-left: 0.5rem !important;
}

/* Alert styling in forms */
.swal2-popup .alert {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border-radius: 0.5rem !important;
}

.swal2-popup .alert-info {
    background: rgba(23, 162, 184, 0.2) !important;
    border-color: rgba(23, 162, 184, 0.3) !important;
    color: #b8daff !important;
}

/* Quill.js Custom Styles */
.quill-editor-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0.375rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

/* Ensure only one toolbar is shown */
.quill-editor-container .ql-toolbar {
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-top: none;
    border-left: none;
    border-right: none;
}

/* Hide any duplicate toolbars */
.quill-editor-container .ql-toolbar + .ql-toolbar {
    display: none !important;
}

/* Ensure proper toolbar positioning */
.quill-editor-container .ql-container {
    border: none;
    font-family: inherit;
}

.quill-editor-container .ql-editor {
    min-height: 250px;
    padding: 1rem;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
}

.quill-editor-container .ql-editor.ql-blank::before {
    color: rgba(0, 0, 0, 0.6);
    font-style: italic;
}

.quill-editor-container .ql-toolbar button {
    color: rgba(255, 255, 255, 0.8);
}

.quill-editor-container .ql-toolbar button:hover {
    color: white;
}

.quill-editor-container .ql-toolbar button.ql-active {
    color: #007bff;
}

.quill-editor-container .ql-toolbar .ql-stroke {
    stroke: currentColor;
}

.quill-editor-container .ql-toolbar .ql-fill {
    fill: currentColor;
}

.quill-editor-container .ql-toolbar .ql-picker {
    color: rgba(255, 255, 255, 0.8);
}

.quill-editor-container .ql-toolbar .ql-picker-options {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
}

.quill-editor-container .ql-toolbar .ql-picker-item {
    color: #333;
}

.quill-editor-container .ql-toolbar .ql-picker-item:hover {
    background: rgba(0, 123, 255, 0.1);
}

.quill-editor-container .ql-toolbar .ql-picker-item.ql-selected {
    background: rgba(0, 123, 255, 0.2);
    color: #007bff;
}

/* Additional rules to prevent duplicate toolbars */
.quill-editor-container .ql-editor:not(:first-child) {
    display: none !important;
}

.quill-editor-container .ql-toolbar:not(:first-child) {
    display: none !important;
}

/* Ensure proper Quill.js layout */
.quill-editor-container .ql-editor-container {
    position: relative;
}

.quill-editor-container .ql-toolbar.ql-snow {
    border: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

.quill-editor-container .ql-container.ql-snow {
    border: none !important;
}

/* Fix any potential z-index issues */
.quill-editor-container .ql-toolbar {
    z-index: 1;
    position: relative;
}

.quill-editor-container .ql-container {
    z-index: 0;
    position: relative;
}

/* Form validation states for Quill editor */
.quill-editor-container.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

.quill-editor-container.is-valid {
    border-color: #198754 !important;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25) !important;
}

/* Error message styling */
.quill-error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
}

.quill-error-message.show {
    display: block;
}