/* Base styles */
@import url('https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@400;500;600;700&family=Krona+One&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Kumbh Sans', sans-serif;
    line-height: 1.6;
    color: #F7F0EB;
    background-color: #16100d;
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #34584B;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Krona One', sans-serif;
    color: #F7F0EB;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Kumbh Sans', sans-serif;
    transition: background-color 0.3s, transform 0.1s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background-color: #34584B;
    color: #F7F0EB;
}

.btn.primary:hover {
    background-color: #2a4a3f;
}

.btn.duplicate {
    background-color: #34584B;
    color: #F7F0EB;
}

.btn.duplicate:hover {
    background-color: #2a4a3f;
}


.btn.small {
    padding: 4px 8px;
    font-size: 12px;
}

.btn.delete {
    background-color: #5e1313;
    color: #F7F0EB;
}

.btn.delete:hover {
    background-color: #4a0f0f;
}

.btn.edit {
    background-color: #34584B;
    color: #F7F0EB;
}

.btn.edit:hover {
    background-color: #2a4a3f;
}

.btn.small.pdf {
    text-wrap-mode: nowrap;
}

/* Documents list */
.documents-container {
    background-color: #0e170e;
    overflow-x: auto; /* Add horizontal scroll capability */
    width: 100%;
}

.documents-header {
    display: flex;
    background-color: #34584B;
    color: #F7F0EB;
    padding: 15px;
    font-weight: bold;
    min-width: 600px; /* Ensure minimum width for mobile scrolling */
}

.document-item {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #202d24;
    transition: background-color 0.2s;
    min-width: 600px; /* Ensure minimum width for mobile scrolling */
}

.document-item:hover {
    background-color: #202d24;
}

.document-item:last-child {
    border-bottom: none;
}

.col {
    flex: 1;
    padding: 0 10px;
}

.col.actions {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

.col:last-child {
    text-align: right; /* Align text to the right in the last column */
}

.no-documents {
    padding: 30px;
    text-align: center;
    color: #a19994;
}

/* Modal */

.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
}

.modal-content {
    position: relative;
    background-color: #0e170e;
    margin: 50px auto;
    padding: 30px;
    width: 80%;
    max-width: 800px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grid layout for document modal */
.wide-modal {
    width: 90%;
    max-width: 1360px; /* Match container max-width */
}

.grid-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.grid-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.image-column .drop-zone {
    height: 100%;
    min-height: 300px;
}

.second-row {
    border-top: 1px solid #34584B;
    padding-top: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.second-row .grid-column {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.desc-column {
    display: flex;
    flex-direction: column;
}

.desc-column .form-group:first-child {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.desc-column textarea {
    flex-grow: 1;
    min-height: 150px;
}

.cost-column {
    display: flex;
    flex-direction: column;
}

.cost-column .form-group {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.cost-column .costo-produzione-container {
    flex-grow: 1;
    min-height: 250px;
    max-height: none;
    overflow-y: auto;
    border: 1px solid #34584B;
    padding: 10px;
    background-color: #0e170e;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .second-row {
        grid-template-columns: 1fr;
    }
    
    .wide-modal {
        width: 95%;
    }
    
    .image-column .drop-zone {
        min-height: 200px;
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #a19994;
    cursor: pointer;
}

.close:hover {
    color: #F7F0EB;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-group.half {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #F7F0EB;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #34584B;
    background-color: #202d24;
    color: #F7F0EB;
    font-size: 14px;
    font-family: 'Kumbh Sans', sans-serif;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #34584B;
}

textarea {
    resize: vertical;
}

.select-with-add {
    display: flex;
    gap: 10px;
}

.select-with-add select {
    flex: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 30px;
}

/* Costo produzione */
.costo-produzione-container {
    margin-bottom: 10px;
}

.costo-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background-color: #202d24;
}

.costo-input-group {
    display: flex;
    flex: 1;
    gap: 10px;
}

.costo-input-group input {
    flex: 1;
}

.costo-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

/* Switch */
.switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #202d24;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: #F7F0EB;
    transition: .4s;
}

input:checked + .slider {
    background-color: #34584B;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Image upload */
.drop-zone {
    width: 100%;
    border: 2px dashed #34584B;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    transition: border-color 0.3s;
    position: relative;
    aspect-ratio: 2/1;
}

.drop-zone:hover,
.drop-zone-over {
    border-color: #34584B;
    background-color: #202d24;
}

.drop-zone-input {
    display: none;
}

.drop-zone-prompt {
    color: #a19994;
    font-size: 14px;
    text-align: center;
}

.image-preview {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.image-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(94, 19, 19, 0.8);
    color: #F7F0EB;
    border: none;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    display: none;
}

.image-delete-btn:hover {
    background-color: rgba(94, 19, 19, 1);
}

/* Options management */
.options-container {
    margin: 20px 0;
}

.options-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.options-form input {
    flex: 1;
}

.options-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #34584B;
    background-color: #0e170e;
}

.options-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #202d24;
}

.options-list li:last-child {
    border-bottom: none;
}

/* Select2 custom styling - Improved */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #34584B !important;
    background-color: #202d24 !important;
    border-radius: 0px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    padding-left: 12px;
    color: #F7F0EB !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #F7F0EB transparent transparent transparent !important;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #F7F0EB transparent !important;
}

.select2-dropdown {
    border: 1px solid #34584B !important;
    background-color: #0e170e !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.select2-container--open .select2-dropdown--below,
.select2-container--open .select2-dropdown--above {
    border: 1px solid #34584B !important;
}

.select2-container--default .select2-results__option {
    color: #F7F0EB !important;
    background-color: #0e170e !important;
    padding: 8px 12px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #34584B !important;
    color: #F7F0EB !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #2a4a3f !important;
}

.select2-search--dropdown .select2-search__field {
    background-color: #202d24 !important;
    color: #F7F0EB !important;
    border: 1px solid #34584B !important;
    padding: 8px;
}

.select2-container--default .select2-selection--multiple {
    background-color: #202d24 !important;
    border: 1px solid #34584B !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #34584B !important;
    border: 1px solid #2a4a3f !important;
    color: #F7F0EB !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #F7F0EB !important;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border: 1px solid #34584B !important;
}

/* Fix for Select2 in modal */
.select2-container {
    z-index: 1040 !important;
}

/* Select2 inside modal should have higher z-index */
.modal .select2-container {
    z-index: 1060 !important; /* Higher than modal */
}

/* Select2 in filters should have lower z-index */
.filter-container .select2-container {
    z-index: 1030 !important; /* Lower than modal */
}

/* SweetAlert2 custom styling */
.swal2-popup {
    background-color: #0e170e !important;
    color: #F7F0EB !important;
    border: 1px solid #34584B !important;
    border-radius: 0px !important;
}

.swal2-title, .swal2-html-container {
    color: #F7F0EB !important;
    font-family: 'Kumbh Sans', sans-serif !important;
}

.swal2-styled.swal2-confirm {
    background-color: #34584B !important;
    font-family: 'Kumbh Sans', sans-serif !important;
}

.swal2-styled.swal2-cancel {
    background-color: #5e1313 !important;
    font-family: 'Kumbh Sans', sans-serif !important;
}

.swal2-icon.swal2-warning {
    border-color: #34584B !important;
    color: #34584B !important;
}

.swal2-icon.swal2-error {
    border-color: #5e1313 !important;
    color: #5e1313 !important;
}

.swal2-icon.swal2-error [class^=swal2-x-mark-line] {
    background-color: #5e1313 !important;
}

.swal2-icon.swal2-success {
    border-color: #34584B !important;
}

.swal2-icon.swal2-success [class^=swal2-success-line] {
    background-color: #34584B !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border-color: #34584B !important;
}

.swal2-input, 
.swal2-textarea, 
.swal2-select {
    background-color: #202d24 !important;
    color: #F7F0EB !important;
    border: 1px solid #34584B !important;
    font-family: 'Kumbh Sans', sans-serif !important;
}

.swal2-radio, 
.swal2-checkbox {
    color: #F7F0EB !important;
}

.swal2-validation-message {
    background-color: #202d24 !important;
    color: #5e1313 !important;
}

.swal2-timer-progress-bar {
    background-color: #34584B !important;
}

.swal2-footer {
    border-top: 1px solid #34584B !important;
    color: #F7F0EB !important;
}

/* Sorting styles */
.sortable {
    cursor: pointer;
    position: relative;
    user-select: none;
}

.sortable:hover {
    background-color: #2a4a3f;
}

.sort-indicator {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: middle;
}

.sort-asc .sort-indicator {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #F7F0EB;
}

.sort-desc .sort-indicator {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #F7F0EB;
}

/* Filter styles */
.filter-container {
    background-color: #0e170e;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #34584B;
}

.filter-container h3 {
    margin-bottom: 15px;
    font-size: 18px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-group {
    flex: 1;
    min-width: 210px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #34584B;
    background-color: #202d24;
    color: #F7F0EB;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

/* Make the filter selects match the document form selects */
.filter-container .select2-container--default .select2-selection--single {
    height: 36px;
}

.filter-container .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
}

.filter-container .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 34px;
}

/* Document count */
.documents-count {
    margin-bottom: 10px;
    color: #a19994;
    font-size: 14px;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .documents-header,
    .document-item {
        min-width: 800px; /* Ensure there's enough width to scroll on mobile */
    }
}

/* Login styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-box {
    background-color: #0e170e;
    padding: 40px;
    border: 1px solid #34584B;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box img {
    margin-bottom: 20px;
}

.login-box h2 {
    margin-bottom: 30px;
}

.login-box .form-group {
    margin-bottom: 25px;
}

.login-box input[type="password"] {
    text-align: center;
    font-size: 16px;
    padding: 12px;
}

.login-box .form-actions {
    justify-content: center;
}
