/* 
    public/css/panel.css - стили для модальных окон, форм и информационной панели
    Оформление: светлая тема, фиолетовые акценты, читаемый текст
*/

/* ========== ПЕРЕМЕННЫЕ ========== */
:root {
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-accent: #6366f1;
    --text-accent-light: #818cf8;
    --text-accent-dark: #4f46e5;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
    --border-radius-base: 12px;
}

/* ========== МОДАЛЬНЫЕ ОКНА ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-surface);
    margin: 10% auto;
    padding: 1.5rem 2rem 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.modal-content.wide-modal {
    max-width: 700px;
}

/* Кнопки закрытия модальных окон */
.modal-content .close-auth,
.modal-content .close-spouse,
.modal-content .close-parents,
.modal-content .close-history,
.modal-content .close-tree {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.modal-content .close-auth:hover,
.modal-content .close-spouse:hover,
.modal-content .close-parents:hover,
.modal-content .close-history:hover,
.modal-content .close-tree:hover {
    color: var(--text-accent);
}

/* ========== ФОРМЫ ========== */
.form-row {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.form-row label {
    margin-bottom: 0.3rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-row input,
.form-row select {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border 0.2s, box-shadow 0.2s;
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.form-row small {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.required-star {
    color: #ef4444;
}

.validation-message {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ========== КНОПКИ ========== */

/* Основная кнопка - тёмно-серая, светлый текст */
.button-std {
    background: #334155;
    color: #f8fafc;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius-base);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.button-std:hover {
    background: #1e293b;
    transform: translateY(-1px);
}

.button-std:active {
    transform: translateY(0);
}

.button-std:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Маленькая светлая кнопка */
.button-small {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 6px 14px;
    border-radius: var(--border-radius-base);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.button-small:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

/* Очень маленькая кнопка для форм */
.small-btn {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.small-btn:hover {
    background: #e2e8f0;
}

/* Кнопка сохранения */
#saveBtn {
    background: #6366f1;
}

#saveBtn:hover {
    background: #4f46e5;
}

/* Кнопка экспорта */
#exportBtn {
    background: #475569;
}

#exportBtn:hover {
    background: #334155;
}

/* Кнопка удаления */
.delete-btn {
    background: #ef4444;
    color: white;
}

.delete-btn:hover:not(:disabled) {
    background: #dc2626;
}

/* Кнопка создания */
.create-btn {
    background: #6366f1;
    color: white;
}

.create-btn:hover {
    background: #4f46e5;
}

/* ========== ИСТОРИЯ ПАРТНЁРОВ ========== */
.history-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.history-row select {
    flex: 2;
    min-width: 150px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
}

.history-row input {
    flex: 3;
    min-width: 150px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
}

.history-row button {
    flex-shrink: 0;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
}

.history-row button:hover {
    background: #dc2626;
}

.info-list {
    background: var(--bg-surface-alt);
    padding: 0.5rem;
    border-radius: 10px;
    margin: 0.3rem 0;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.info-item {
    padding: 0.2rem 0;
}

/* ========== ФОРМА РЕДАКТОРА ========== */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* ========== ФОТОГРАФИИ ========== */
.photo-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.member-photo {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 60px;
    background: var(--bg-surface-alt);
}

.photo-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Обёртка фото с оверлеем */
.photo-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 60px;
    overflow: hidden;
    cursor: pointer;
}

.photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.photo-wrapper:hover .photo-overlay {
    opacity: 1;
}

.photo-add-btn,
.photo-remove-btn {
    background: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.photo-add-btn:hover,
.photo-remove-btn:hover {
    transform: scale(1.05);
}

/* ========== КОМПОНЕНТ ВВОДА ДАТЫ ========== */
.date-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.date-format-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-format-btn {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.date-format-btn:hover {
    background: #e2e8f0;
}

.date-format-btn.active {
    background: var(--text-accent);
    color: white;
    border-color: var(--text-accent);
}

.date-input-fields {
    background: var(--bg-surface-alt);
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.date-field-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.date-field-group input {
    text-align: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 0.9rem;
    width: auto;
    min-width: 60px;
}

.date-field-group input.error {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.date-field-group span {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-secondary);
}

/* ========== ИНФОРМАЦИОННАЯ ПАНЕЛЬ (дублируется из styles.css для совместимости) ========== */
.info-panel {
    position: fixed;
    right: -480px;
    top: 50%;
    transform: translateY(-50%);
    width: 480px;
    max-width: 90vw;
    background: var(--bg-surface);
    border-radius: 24px 0 0 24px;
    padding: 24px;
    overflow-y: auto;
    max-height: 90vh;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.info-panel.visible {
    right: 0;
}

.close-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-panel:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

.panel-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border-color);
    display: inline-block;
}

.person-detail-card {
    display: flex;
    gap: 20px;
    background: var(--bg-surface-alt);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 600px) {
    .person-detail-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .person-detail-info {
        text-align: center;
    }
}

.person-detail-photo {
    flex-shrink: 0;
}

.person-detail-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--text-accent);
    box-shadow: var(--shadow-sm);
}

.person-detail-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--text-accent), var(--text-accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 600;
    color: white;
    box-shadow: var(--shadow-sm);
}

.person-detail-info {
    flex: 1;
}

.person-detail-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.person-detail-firstname {
    font-size: 0.85rem;
    color: var(--text-accent);
    margin-bottom: 8px;
    font-weight: 500;
}

.person-detail-dates {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.person-detail-gender {
    font-size: 0.8rem;
    color: var(--text-accent);
    background: rgba(99, 102, 241, 0.1);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    margin-top: 8px;
}

.person-detail-address {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Секция партнёра */
.partner-section .person-detail-card {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.05), rgba(99, 102, 241, 0.05));
    border: 1px solid rgba(236, 72, 153, 0.2);
}

/* Сетка детей */
.children-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    justify-content: flex-start;
}

@media (max-width: 500px) {
    .children-grid {
        flex-direction: column;
    }
}

.child-card {
    min-width: 140px;
    max-width: 100%;
    flex: 1;
    background: var(--bg-surface-alt);
    border-radius: var(--border-radius-base);
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.child-card:hover {
    background: var(--bg-surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.child-photo {
    flex-shrink: 0;
}

.child-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--text-accent-light);
}

.child-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c7d2fe, #a5b4fc);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.child-info {
    flex: 1;
}

.child-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.child-years {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.no-data {
    color: var(--text-secondary);
    font-style: italic;
    padding: 16px;
    text-align: center;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.panel-section {
    animation: fadeIn 0.3s ease-out;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    .modal-content {
        margin: 20% auto;
        padding: 1rem;
        width: 95%;
    }
    
    .info-panel {
        width: 100%;
        right: -100%;
        border-radius: 24px 24px 0 0;
        top: auto;
        bottom: 0;
        transform: none;
        max-height: 70vh;
    }
    
    .info-panel.visible {
        right: 0;
        bottom: 0;
        top: auto;
    }

    .person-detail-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .child-card {
        min-width: 100%;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .button-std {
        width: 100%;
    }
}