.modal {
    display: none;
    position: absolute; /* Positioning relative to the button */
    left: 200px;
    top: 200px;
    z-index: 110;
    background-color: rgba(0, 0, 0, 0.7);
    width: 300px;
}

.modal ul {
    list-style-type: none;
}

/* Modal Content */
.modal-content {
    background-color: white;
    padding: 20px;
    border: 1px solid #888;
}

/* Close Button */
.close-modal { position: relative;  font-size: 32px;  color: #aaa; cursor: pointer; width: 100%; display: flex;  justify-content: end; }

.close-modal:hover,
.close-modal:focus {
    color: black;
}

/* Basic styling for the modal */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Background overlay */
    padding-top: 100px; /* Center the modal */
    box-sizing: border-box;
}

.show {
    display: flex; /* Show the modal with flexbox */
    justify-content: center; /* Horizontally center */
    align-items: center; /* Vertically center */
}

.modal-content {
    position: relative;
    background-color: white;
    margin: 5% auto;
    padding: 24px 32px 40px 32px;
    border-radius: 8px;
    /*width: 500px;
    height: 300px; */
    max-width: 500px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.modal-title {
    margin: 10px 0 10px 0;
    font-size: 20px;
}

.modal-description {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #555;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.modal-content-large {
    display: flex;
    flex-direction: column;
    background-color: white;
    margin: auto;
    padding: 20px;
    border-radius: 5px;
    box-sizing: border-box;
    /* Grows with the window but never too small or too big: min, preferred, max */
    width: clamp(320px, 85vw, 1200px);
    height: clamp(400px, 80vh, 900px);
    max-height: calc(100vh - 40px);
    text-align: center;
    overflow-y: auto;
}

/* Touch devices: don't hand scrolling over to the page when a modal area hits its end
   (wheel/trackpad is handled in general.js) */
.modal,
.modal * {
    overscroll-behavior: contain;
}

/* Lock the page behind an open modal (keyboard and scrollbar scrolling too).
   Modals are opened with addClass('show') and closed either with removeClass('show')
   or with jQuery fadeOut(), which leaves .show but sets an inline display: none. */
html:has(.modal.show:not([style*="display: none"])) {
    overflow: hidden;
}

/* The media selector sizes to its content (10 rows + controls) instead of 80vh;
   max-height above still caps it and the rows scroll inside (see main.css) */
#mediaSelector .modal-content-large {
    height: auto;
}

/* The overlay's 100px top padding steals too much height on short laptop screens */
.modal:has(.modal-content-large) {
    padding: 20px;
}

/* Phones / very narrow windows: use (almost) the whole screen */
@media (max-width: 600px) {
    .modal-content-large {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .modal:has(.modal-content-large) {
        padding: 0;
    }
}

/* Modal input field */
#newPlaceModal #folderName {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #4CAF50;
    border-radius: 5px;
    font-size: 16px;
    text-align: center;
}

/* Modal buttons */
#newPlaceModal .modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

#newPlaceModal .cancel-btn {
    background-color: var(--warning-red);
    color: white;
}

#newPlaceModal .create-btn {
    background-color: var(--ok-green);
    color: var(--text-on-ok-green);
}

/* Hover effects */
#newPlaceModal button:hover {
    opacity: 0.8;
}

#newPlaceTitle {
    max-width: 750px;
    min-width: 400px;
    padding: 4px 8px;
    margin: 24px 0 0 0;
}

/* New app modal */
#newAppModal .modal-content {
    display: flex;
    flex-direction: column;
}

#newAppModal label {
    margin-top: 16px;
}

#newAppName,
#newAppOrganization {
    max-width: 750px;
    min-width: 400px;
    padding: 4px 8px;
    margin: 8px 0 0 0;
}

#newAppModal .modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

#newAppModal button {
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#newAppModal button:hover {
    opacity: 0.8;
}

#newAppModal button:disabled {
    opacity: 0.5;
    cursor: default;
}

#newAppCancelBtn {
    border: 1px solid var(--warning-red) !important;
    background: white;
    color: var(--warning-red);
    margin: 0;
}

@media (max-width: 600px) {
    #newAppName,
    #newAppOrganization {
        min-width: 0;
        width: 100%;
    }
}

#newPlaceModal button {
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
#cancelBtn {
    border: 1px solid var(--warning-red) !important;
    background:white;
    color: var(--warning-red);
    margin: 0;
}

#confirmBtn {
    background: var(--warning-red);
    border: none;
}
#confirmCancelBtn {
    margin: 0;
    font-weight: 300;
}

.modal-options {
    display: flex;
    flex-direction: column;   /* stack vertically */
    gap: 1rem;                /* equal space between buttons */
    padding: 0;
    margin: 0;
    list-style: none;
}

.modal-options li {
    flex: 1;                  /* make all buttons equal width */
    padding: 12px;
    text-align: center;
    background: #f0f0f0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-options li:hover {
    background: #e0e0e0;
}

.modal-options .icon {
    margin-right: 8px;
}
/* New organization modal */
#newOrganizationModal .modal-content {
    display: flex;
    flex-direction: column;
}

#newOrganizationModal label {
    margin-top: 16px;
}

#newOrganizationName {
    max-width: 750px;
    min-width: 400px;
    padding: 4px 8px;
    margin: 8px 0 0 0;
}

#newOrganizationModal .modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

#newOrganizationModal button {
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#newOrganizationModal button:hover {
    opacity: 0.8;
}

#newOrganizationModal button:disabled {
    opacity: 0.5;
    cursor: default;
}

#newOrganizationCancelBtn {
    border: 1px solid var(--warning-red) !important;
    background: white;
    color: var(--warning-red);
    margin: 0;
}

@media (max-width: 600px) {
    #newOrganizationName {
        min-width: 0;
        width: 100%;
    }
}
