/* prompts-modal.css - Стили модального окна промптов (Mobile Responsive) */

/* ============================================
   OVERLAY
   ============================================ */
.prompts-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9000;  /* Ниже чем модалка подтверждения (10000) */
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    animation: overlayFadeIn 0.2s ease;
}

.prompts-modal-overlay.active {
    display: flex;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.prompts-modal {
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: translateY(-20px) scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* ============================================
   HEADER WITH SEARCH
   ============================================ */
.prompts-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a2a;
}

.prompts-search-icon {
    color: #666;
    flex-shrink: 0;
}

.prompts-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #d4d4d4;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    min-height: 24px;
}

.prompts-search-input::placeholder {
    color: #666;
}

.prompts-modal-close {
    background: transparent;
    border: none;
    color: #666;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.prompts-modal-close:hover {
    background: #2a2a2a;
    color: #999;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.prompts-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.prompts-modal-content::-webkit-scrollbar {
    width: 6px;
}

.prompts-modal-content::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.prompts-modal-content::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* ============================================
   NEW PROMPT BUTTON
   ============================================ */
.new-prompt-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: rgba(107, 136, 105, 0.15);
    border: 1px solid rgba(107, 136, 105, 0.3);
    border-radius: 12px;
    color: #6b8869;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.new-prompt-btn:hover {
    background: rgba(107, 136, 105, 0.25);
    border-color: #6b8869;
}

.new-prompt-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.prompts-section-header {
    padding: 12px 16px 8px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   PROMPT ITEMS
   ============================================ */
.prompt-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
    min-height: 60px;
    -webkit-tap-highlight-color: transparent;
}

.prompt-item:hover {
    background: #2a2a2a;
}

.prompt-item.active {
    background: rgba(107, 136, 105, 0.15);
}

.prompt-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #888;
    font-size: 18px;
}

.prompt-item.active .prompt-item-icon {
    background: rgba(107, 136, 105, 0.3);
    color: #6b8869;
}

.prompt-item-content {
    flex: 1;
    min-width: 0;
}

.prompt-item-name {
    font-size: 14px;
    color: #d4d4d4;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.prompt-item-preview {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-item-model {
    font-size: 11px;
    color: #6b8869;
    background: rgba(107, 136, 105, 0.15);
    padding: 4px 10px;
    border-radius: 6px;
    flex-shrink: 0;
}

.prompt-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.prompt-item:hover .prompt-item-actions {
    opacity: 1;
}

.prompt-action-btn {
    background: transparent;
    border: none;
    color: #666;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.prompt-action-btn:hover {
    background: #333;
    color: #999;
}

.prompt-action-btn.delete:hover {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.prompts-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.prompts-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.prompts-empty-text {
    font-size: 14px;
    margin-bottom: 8px;
}

.prompts-empty-hint {
    font-size: 12px;
    color: #555;
}

/* ============================================
   EDIT/CREATE FORM
   ============================================ */
.prompt-form {
    padding: 20px;
    border-top: 1px solid #2a2a2a;
    background: #1a1a1a;
    border-radius: 0 0 16px 16px;
}

.prompt-form-row {
    margin-bottom: 16px;
}

.prompt-form-label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    font-weight: 500;
}

.prompt-form-input {
    width: 100%;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    color: #d4d4d4;
    font-size: 15px;
    font-family: inherit;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.2s;
    min-height: 48px;
}

.prompt-form-input:focus {
    border-color: #6b8869;
}

.prompt-form-input::placeholder {
    color: #555;
}

textarea.prompt-form-input {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

/* ============================================
   MODEL SELECTOR IN FORM
   ============================================ */
.prompt-model-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.prompt-model-option {
    padding: 10px 16px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

.prompt-model-option:hover {
    background: #2a2a2a;
    border-color: #444;
    color: #999;
}

.prompt-model-option.selected {
    background: rgba(107, 136, 105, 0.2);
    border-color: #6b8869;
    color: #6b8869;
}

/* ============================================
   FORM ACTIONS
   ============================================ */
.prompt-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.prompt-form-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.prompt-form-btn.cancel {
    background: transparent;
    border: 1px solid #333;
    color: #888;
}

.prompt-form-btn.cancel:hover {
    background: #2a2a2a;
    color: #999;
}

.prompt-form-btn.save {
    background: #6b8869;
    border: none;
    color: #fff;
}

.prompt-form-btn.save:hover {
    background: #7a9978;
}

.prompt-form-btn.save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   SAFE AREA INSETS
   ============================================ */
@supports (padding: max(0px)) {
    .prompts-modal-overlay {
        padding-top: max(80px, env(safe-area-inset-top) + 40px);
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* ============================================
   TABLET RESPONSIVE (768px)
   ============================================ */
@media (max-width: 768px) {
    .prompts-modal-overlay {
        padding-top: 20px;
        padding-left: 12px;
        padding-right: 12px;
        align-items: flex-end;
    }
    
    .prompts-modal {
        max-height: calc(100vh - 40px);
        max-height: calc(100dvh - 40px);
        border-radius: 16px 16px 0 0;
        animation: modalSlideUp 0.2s ease;
    }
    
    @keyframes modalSlideUp {
        from { 
            opacity: 0; 
            transform: translateY(100%); 
        }
        to { 
            opacity: 1; 
            transform: translateY(0); 
        }
    }
    
    .prompts-modal-header {
        padding: 14px 16px;
    }
    
    .prompts-search-input {
        font-size: 16px;
    }
    
    .prompt-item {
        padding: 12px 14px;
    }
    
    .prompt-item-icon {
        width: 36px;
        height: 36px;
    }
    
    .prompt-form {
        padding: 16px;
    }
    
    .prompt-model-selector {
        gap: 6px;
    }
    
    .prompt-model-option {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Show actions on touch */
    .prompt-item-actions {
        opacity: 0.6;
    }
    
    .prompt-item:hover .prompt-item-actions {
        opacity: 1;
    }
}

/* ============================================
   SMALL PHONES (480px)
   ============================================ */
@media (max-width: 480px) {
    .prompts-modal-overlay {
        padding: 0;
    }
    
    .prompts-modal {
        max-width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    
    .prompt-item-model {
        display: none;
    }
    
    .prompt-item-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .prompt-item-name {
        font-size: 13px;
    }
    
    .prompt-item-preview {
        font-size: 11px;
    }
    
    .prompt-form-actions {
        flex-direction: column;
    }
    
    .prompt-form-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* ============================================
   TOUCH DEVICE ADJUSTMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .prompt-item-actions {
        opacity: 0.5;
    }
    
    .prompt-action-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .prompt-item,
    .new-prompt-btn,
    .prompt-model-option,
    .prompt-form-btn {
        min-height: 52px;
    }
}
