/* ==============================
   SHARED MODAL SYSTEM
   ============================== */

/* CSS Variables for modal styling - matches modern-ui-system.css */
:root {
    --modal-text-white: #EEFDF9;
    --modal-element-bg: #EEFDF910;
    --modal-element-bg-hover: #EEFDF950;
    --modal-element-bg-equipment: #EEFDF970;
}

/* Base modal overlay - covers entire screen with backdrop */
.standard-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;

    /* Enable click-outside-to-close functionality */
    cursor: pointer;

    /* iOS Safari optimizations */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.standard-modal-overlay.active {
    opacity: 1;
    visibility: visible;
    z-index: 1102;
    /* Ensure overlay is above the workout generated modal */
}

/* Base modal container - slides up from bottom */
.standard-modal {
    position: fixed;
    left: 0;
    width: 100vw;
    width: 100dvw;
    background-color: #1a1a1a;
    border-radius: 28px 28px 0 0;
    padding: 24px;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 1000;
    transform: translateY(100vh);
    transition: transform 0.3s ease-out;
    bottom: 0;
    font-family: 'Inter', sans-serif;

    /* Prevent click events from bubbling to overlay */
    cursor: default;

    /* iOS Safari optimizations */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Prevent iOS Safari from shifting viewport */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}

.standard-modal.active {
    transform: translateY(0);
}

/* ==============================
   MODAL SIZE VARIANTS
   ============================== */

/* Simple modals - confirmations, basic forms */
.standard-modal-simple {
    height: auto;
    max-height: 50vh;
    min-height: 300px;
}

/* Medium modals - complex forms */
.standard-modal-medium {
    height: 60vh;
}

/* Large modals - complex interfaces, charts */
.standard-modal-large {
    height: 80vh;
    overflow-y: auto;
}

/* ==============================
   COMMON MODAL ELEMENTS
   ============================== */

/* Modal header */
.standard-modal-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.standard-modal-title {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 28px;
    color: #fff;
    margin: 0;
}

/* Modal close button */
.standard-modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.standard-modal-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.standard-modal-close-btn .close-icon {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.standard-modal-close-btn .close-line {
    position: absolute;
    width: 18px;
    height: 2px;
    background-color: #fff;
    border-radius: 1px;
}

.standard-modal-close-btn .close-line:first-child {
    transform: rotate(45deg);
}

.standard-modal-close-btn .close-line:last-child {
    transform: rotate(-45deg);
}

/* Modal body */
.standard-modal-body {
    margin-bottom: 24px;
}

/* Modal content text centering */
.modal-description {
    text-align: center;
}

#modal-delete-day-workout-name {
    text-align: center;
}

/* Modal actions/buttons container */
.standard-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: auto;
}

/* ==============================
   MODAL FORM ELEMENTS
   ============================== */

/* Input and textarea styles for standard modals */
.standard-modal input,
.standard-modal select,
.standard-modal textarea {
    background: var(--modal-element-bg) !important;
    border: 2px solid var(--modal-element-bg) !important;
    color: var(--modal-text-white) !important;
    border-radius: 12px !important;
    font-family: 'Inter', sans-serif !important;
    padding: 12px 16px !important;
    width: 100%;
    box-sizing: border-box;
    /* Font size 16px prevents iOS zoom on focus */
    font-size: 16px !important;
    /* Prevent text selection in input fields on iOS */
    -webkit-user-select: text;
    user-select: text;
    /* Remove tap highlight on iOS */
    -webkit-tap-highlight-color: transparent;
    /* Prevent double-tap zoom on iOS */
    touch-action: manipulation;
}

.standard-modal input:focus,
.standard-modal select:focus,
.standard-modal textarea:focus {
    background: var(--modal-element-bg-hover) !important;
    border-color: var(--modal-element-bg-hover) !important;
    outline: none !important;
}

.standard-modal input:hover,
.standard-modal select:hover,
.standard-modal textarea:hover {
    background: var(--modal-element-bg-hover) !important;
    border-color: var(--modal-element-bg-hover) !important;
}

/* Placeholder text */
.standard-modal input::placeholder,
.standard-modal textarea::placeholder {
    color: rgba(238, 253, 249, 0.6) !important;
}

/* Textarea specific styles */
.standard-modal textarea {
    resize: vertical;
    min-height: 80px;
}

/* Location items need proper text color */
.standard-modal .location-item {
    color: var(--modal-text-white) !important;
}

/* ==============================
   RESPONSIVE ADJUSTMENTS
   ============================== */

@media (max-width: 768px) {
    .standard-modal {
        padding: 20px;
    }

    .standard-modal-title {
        font-size: 24px;
    }

    .standard-modal-simple {
        min-height: 250px;
    }

    .standard-modal-actions {
        flex-direction: column-reverse;
    }

    .standard-modal-actions .btn {
        width: 100%;
    }
}

/* ==============================
   SAFE AREA SUPPORT (iOS)
   ============================== */

.standard-modal {
    /* Safe area support for iPhone bottom safe area */
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(24px + env(safe-area-inset-left, 0px));
    padding-right: calc(24px + env(safe-area-inset-right, 0px));
}