/* =========================================
   3. МОДУЛЬ ПЛАНИРОВЩИКА (PLANNER)
   ========================================= */

#couple-screen {
    background-color: #f8faff;
    flex-direction: column;
    height: 100vh;
    padding: 0;
}

/* ШАПКА & ТАБЫ */
.couple-header-fixed {
    padding: 15px;
    padding-top: env(safe-area-inset-top, 40px);
    /* Safe area logic */
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.tabs {
    display: flex;
    background: #f1f3f5;
    border-radius: 15px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    color: #868e96;
    transition: 0.2s;
    font-size: 0.9rem;
    cursor: pointer;
}

.tab-btn.active {
    background: #fff;
    color: #228be6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
    padding-top: 20px;
}

.tab-content.active {
    display: block;
}

.content-area {
    padding: 0 15px 120px;
    overflow-y: auto;
    flex: 1;
}

/* ГЛАВНЫЙ КОНТЕНТ */
.couple-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 100px;
}

/* СПИСКИ (ИДЕИ) */
#ideas-list {
    list-style: none;
    padding: 15px;
}

#add-idea-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #228be6;
    color: white;
    border: none;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(34, 139, 230, 0.3);
    flex-shrink: 0;
}

.idea-item {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
}

.idea-item.match-gold {
    background: linear-gradient(135deg, #fff9db, #fff3bf);
    border: 1px solid #fcc419;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    transform: scale(1.02);
}

.vote-btn {
    background: #fff5f5;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.vote-btn.voted {
    background: #ff6b6b;
    color: #fff;
}

/* ВВОД ДАННЫХ */
.floating-input-area {
    position: fixed;
    bottom: 20px;
    left: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    background: #fff;
    padding: 10px;
    border-radius: 30px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 200;
}

#new-idea-input {
    flex: 1;
    border: none;
    padding: 10px 15px;
    font-size: 1rem;
    outline: none;
}

/* ГАЛЕРЕЯ (POLAROID) */
.polaroid-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 15px;
}

.polaroid-frame {
    background: #fff;
    padding: 10px 10px 30px 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    border-radius: 2px;
    transform: rotate(-1deg);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    text-align: center;
}

.polaroid-frame img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #eee;
}

.polaroid-frame:nth-child(even) {
    transform: rotate(1.5deg);
}

.polaroid-frame:hover {
    transform: rotate(0) scale(1.03);
    z-index: 10;
}

/* ЧАТ / СООБЩЕНИЯ */
.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    max-width: 85%;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.send-btn-modern {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #228be6;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn-modern:hover {
    background: #1c7ed6;
    transform: translateY(-2px);
}

.send-btn-modern:active {
    transform: translateY(0) scale(0.95);
}

.cat-chip {
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: #343a40;
    color: white !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.message-mine {
    background: linear-gradient(135deg, #339af0, #228be6);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-partner {
    background: #f1f3f5;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* ГАЛЕРЕЯ И ВЛОЖЕНИЯ */
.gallery-grid {
    display: grid;
    gap: 10px;
}

.gallery-item-wrapper {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #f1f3f5;
    border: 1px solid #e9ecef;
}

.gallery-item {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.photo-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.cover-checkbox {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    z-index: 10;
}

.cover-checkbox.active {
    background: #ffc107;
    color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* КНОПКИ */
.close-btn-premium {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f3f5;
    border: none;
    font-size: 22px;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.close-btn-premium:hover {
    background: #e9ecef;
    transform: rotate(90deg);
}

.cat-chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white !important;
}

#send-chat-btn,
#event-send-chat-btn {
    transition: transform 0.2s;
    background: #228be6;
}

#send-chat-btn:active,
#event-send-chat-btn:active {
    transform: scale(0.9);
}

/* АДАПТИВНОСТЬ */
@media screen and (max-width: 600px) {
    .polaroid-grid {
        grid-template-columns: 1fr;
    }

    .floating-input-area {
        bottom: 20px;
        left: 20px;
        right: 20px;
    }
}

/* МОДАЛЬНЫЕ ОКНА: НОВЫЙ СТИЛЬ */
.modal-content {
    background: #fff;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* VIEW VS EDIT TOGGLES */
.content-view-mode,
.content-edit-mode {
    display: none;
}

.content-view-mode.active,
.content-edit-mode.active {
    display: block;
}

/* ТИПОГРАФИКА ПРОСМОТРА */
.view-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: #212529;
}

.view-title-large {
    font-size: 1.8rem;
    font-weight: 900;
    margin: 0;
    color: #1a1a1a;
}

.view-description {
    color: #495057;
    line-height: 1.6;
    margin-bottom: 24px;
}

.view-description-premium {
    font-family: 'Georgia', serif;
    font-size: 1.05rem;
    line-height: 1.8;
    color: #343a40;
    margin-bottom: 30px;
    white-space: pre-wrap;
}

.view-date {
    font-size: 0.9rem;
    color: #868e96;
    font-weight: 600;
    margin-bottom: 20px;
}

/* ГАЛЕРЕЯ ПРОСМОТРА */
.gallery-grid-view {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.artifact-gallery .gallery-item-wrapper {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 4px solid #fff;
}

/* АККОРДЕОН */
.accordion {
    border: 1px solid #f1f3f5;
    border-radius: 16px;
    margin: 24px 0;
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    padding: 16px;
    background: #f8f9fa;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: #495057;
    cursor: pointer;
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #fff;
}

.accordion-body.active {
    max-height: 500px;
}

/* ЧАТ ВНУТРИ МОДАЛКИ */
.chat-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.chat-input-row {
    padding: 12px 16px;
    border-top: 1px solid #f1f3f5;
    display: flex;
    gap: 8px;
}

.chat-input-row input {
    flex: 1;
    border: none;
    background: #f1f3f5;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* ФУТЕР МОДАЛКИ */
.modal-footer-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
}

.primary-action-btn {
    background: #228be6;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
}

.secondary-action-btn {
    background: #f1f3f5;
    color: #495057;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
}

.danger-text-btn {
    background: none;
    border: none;
    color: #fa5252;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.premium-input-ghost {
    font-size: 1.1rem;
    font-weight: 800;
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 0;
    border-bottom: 2px solid #f1f3f5;
    margin-bottom: 16px;
}

.premium-textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid #f1f3f5;
    border-radius: 12px;
    padding: 12px;
    font-family: inherit;
    resize: none;
}

.edit-section-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #adb5bd;
    text-transform: uppercase;
    margin: 20px 0 10px;
}

.artifact-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #fab005;
}

.add-photo-btn {
    display: block;
    text-align: center;
    padding: 12px;
    background: #fff9db;
    color: #f08c00;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 12px;
    cursor: pointer;
}

@media screen and (orientation: landscape) and (max-height: 500px) {
    .modal-content {
        max-width: 90vw;
        max-height: 90vh;
    }

    .modal-body {
        max-height: 60vh !important;
    }
}

/* 1.3 Polaroid Collage Fix */
.polaroid-img-wrapper {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #eee;
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Slight border for frame */
}

.polaroid-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: inherit;
    opacity: inherit;
    transition: transform 0.3s ease;
}

/* 1.5 Formatting Toolbar */
.format-toolbar {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 4px;
    border-bottom: 1px solid #f1f3f5;
}

.format-btn {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #495057;
    cursor: pointer;
    transition: all 0.1s;
}

.format-btn:hover {
    background: #f8f9fa;
    color: #228be6;
}

.format-btn.active {
    background: #e7f5ff;
    color: #1971c2;
    border-color: #74c0fc;
}

/* =========================================
   A. ADAPTIVE LAYOUTS (DESKTOP & TABLET)
   ========================================= */

/* 1. Large Desktop (Split View Potential) */
@media (min-width: 1024px) {

    /* Override global centering for Planner to allow wider view */
    #couple-screen {
        max-width: 900px !important;
        flex-direction: row;
        align-items: flex-start;
        padding: 40px;
        background: transparent !important;
        box-shadow: none !important;
        gap: 20px;
    }

    #couple-screen>* {
        /* Columns */
        background: #fff;
        border-radius: 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
        height: 85vh;
        /* Fixed height container */
        overflow: hidden;
    }

    /* Left Column (Navigation & List) */
    .couple-header-fixed,
    .couple-body {
        padding: 0;
        box-shadow: none;
    }

    /* Make body scrollable independently */
    .content-area {
        height: 100%;
        overflow-y: auto;
    }

    /* Adjust Modals to be centered popups */
    .modal-content {
        max-width: 600px;
        border-radius: 20px;
        bottom: auto;
        /* Not stuck to bottom */
        position: relative;
        animation: none;
        /* Disable mobile slideUp */
        transform: none;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
        margin: auto;
        /* Flex centering helper */
        max-height: 85vh;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: scale(0.95);
        }

        to {
            opacity: 1;
            transform: scale(1);
        }
    }
}

/* 2. Tablet / Landscape Mobile */
@media (min-width: 600px) and (max-width: 1023px) {

    /* Keep mobile width but centered (handled by ui.css), optimize modals */
    .modal-content {
        max-width: 500px;
        bottom: auto;
        position: relative;
        border-radius: 20px;
    }
}

/* 3. Landscape specific optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    .modal-content {
        flex-direction: row;
        max-width: 80vw;
    }

    .modal-body {
        max-height: 80vh !important;
    }
}