/* ==========================================
   ПРОСТРАНСТВО СМЫСЛОВ — ОБЩИЕ СТИЛИ
   ========================================== */

/* ---------- ПЕРЕМЕННЫЕ ---------- */
:root {
    --color-bg:            #faf7f2;
    --color-white:         #ffffff;
    --color-dark:          #2c2c2c;
    --color-text:          #4a3a2a;
    --color-text-dim:      #5a4a3a;
    --color-text-gray:     #7a6a5a;
    --color-border:        #e8e0d5;
    --color-border-hover:  #b87c5e;
    --color-accent:        #b87c5e;
    --color-accent-hover:  #9a5e42;
    --color-green:         #4a7c5e;
    --color-green-bg:      #e0f0e8;
    --color-green-light:   #eef4ea;
    --color-gold:          #e6b422;
    --color-header-bg:     #2c2c2c;
    --color-header-text:   #e8ddcf;
    --color-track:         #f0e8df;
    --color-brown:         #7f6b5f;
    --color-brown-dark:    #8b5a4a;
    --color-warning-bg:    #fff0e0;
    --color-light-bg:      #faf7f2;

    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;

    --radius-sm:  12px;
    --radius-md:  16px;
    --radius-lg:  24px;
    --radius-xl:  32px;
    --radius-btn: 30px;
}

/* ---------- СБРОС ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--color-bg);
    font-family: var(--font-body);
    color: var(--color-dark);
    line-height: 1.5;
}

/* ---------- СКРОЛЛБАРЫ ---------- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--color-track);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 3px;
}

/* ---------- БАЗОВЫЕ ФОРМЫ ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
textarea,
select {
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: var(--color-white);
    color: var(--color-dark);
    width: 100%;
    transition: border-color 0.2s;
}
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
}
textarea {
    resize: vertical;
    min-height: 80px;
}
label {
    font-size: 0.85rem;
    color: var(--color-text-dim);
    font-weight: 500;
}

/* ---------- БАЗОВЫЕ КНОПКИ ---------- */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--radius-btn);
    font-size: 0.9rem;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    text-decoration: none;
    text-align: center;
}
.btn-primary {
    background: var(--color-dark);
    color: var(--color-header-text);
}
.btn-primary:hover {
    background: #4a3a2a;
}
.btn-accent {
    background: var(--color-accent);
    color: var(--color-white);
}
.btn-accent:hover {
    background: var(--color-accent-hover);
}
.btn-outline {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-gray);
}
.btn-outline:hover {
    background: var(--color-light-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.btn-green {
    background: var(--color-green);
    color: var(--color-white);
}
.btn-green:hover {
    background: #3a6b4e;
}
.btn-danger {
    background: var(--color-brown-dark);
    color: var(--color-header-text);
}

/* ---------- ПУСТОЕ СОСТОЯНИЕ ---------- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-gray);
}

/* ---------- ХЕДЕР ---------- */
.top-bar {
    background: var(--color-header-bg);
    padding: 16px 32px;
    position: relative;
    margin-bottom: 60px;
}
.top-bar-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo-area {
    display: flex;
    align-items: baseline;
    gap: 20px;
}
.logo-link {
    text-decoration: none;
    display: flex;
    align-items: baseline;
    gap: 20px;
}
.chinese-char {
    font-size: 4rem;
    font-family: "KaiTi", "华文楷书", "Microsoft YaHei", "Noto Serif SC", serif;
    color: var(--color-gold);
    font-weight: 500;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.logo-text {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--color-header-text);
    letter-spacing: 1px;
}
.top-avatar {
    position: relative;
    top: 32px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.top-avatar-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--color-bg);
    background: var(--color-header-text);
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.user-id-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 12px;
}
.user-id-text {
    font-size: 0.7rem;
    color: var(--color-header-text);
    font-family: monospace;
}
.user-id-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.copy-id-btn {
    background: none;
    border: none;
    color: var(--color-header-text);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
.copy-id-btn:hover {
    background: rgba(232, 221, 207, 0.2);
}

/* ---------- МЕНЮ ПОЛЬЗОВАТЕЛЯ ---------- */
.user-menu-container {
    position: relative;
    display: inline-block;
}
.user-name-clickable {
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-header-text);
    transition: opacity 0.2s;
}
.user-name-clickable:hover {
    opacity: 0.8;
}
.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 180px;
    z-index: 100;
    display: none;
    margin-top: 8px;
}
.user-menu.show {
    display: block;
}
.user-menu a {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--color-dark);
    font-size: 0.9rem;
    transition: background 0.2s;
}
.user-menu a:hover {
    background: var(--color-light-bg);
}
.user-menu hr {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--color-track);
}

/* ---------- СЕТКА ГЛАВНОЙ ---------- */
.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px 40px 32px;
    display: grid;
    grid-template-columns: 300px 1fr 320px;
    gap: 32px;
    align-items: start;
}

/* ---------- ЛЕВАЯ КОЛОНКА ---------- */
.sidebar-left {
    background: transparent;
}
.friends-section {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    overflow: hidden;
}
.friends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 16px 20px;
    border-bottom: 1px solid var(--color-track);
    flex-shrink: 0;
    background: var(--color-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.friends-header h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-dark);
    margin: 0;
}
.friend-search {
    display: flex;
    gap: 8px;
}
.friend-search input {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.8rem;
    width: 100px;
}
.friend-search button {
    background: var(--color-header-text);
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--color-text-dim);
    transition: background 0.2s;
}
.friend-search button:hover {
    background: #d8cbbe;
}
.friend-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
    margin: 0;
}
.friend-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-track);
    transition: background 0.2s;
    border-radius: var(--radius-sm);
}
.friend-item:hover {
    background: var(--color-light-bg);
}
.friend-item:last-child {
    border-bottom: none;
}
.friend-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    flex: 1;
}
.friend-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-header-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: #7a5a46;
    font-size: 1rem;
    flex-shrink: 0;
}
.friend-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}
.friend-info {
    flex: 1;
}
.friend-name {
    font-weight: 500;
    font-size: 1rem;
    color: var(--color-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
.friend-status {
    font-size: 0.75rem;
    color: var(--color-text-gray);
    margin-top: 2px;
}

/* ---------- ПРАВАЯ КОЛОНКА ---------- */
.right-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}
.right-card h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--color-dark);
}

/* ---------- ЗАГОЛОВКИ СТРАНИЦ ---------- */
.feed-title-large {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    color: var(--color-dark);
    margin-bottom: 0.5rem;
}
.feed-subtitle {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--color-dark);
    margin: 0 0 1.5rem 0;
}
.profile-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    color: var(--color-dark);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 16px;
}
.senses-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 2rem 0 1.5rem 0;
}
.senses-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--color-dark);
}

/* ---------- КНОПКА ДРУГА ---------- */
.friend-button {
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-btn);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    margin-left: 16px;
}
.friend-button:hover {
    background: var(--color-accent-hover);
}
.friend-button.removed {
    background: var(--color-text-gray);
}

/* ---------- АДАПТИВНОСТЬ: ПЛАНШЕТ ---------- */
@media (max-width: 1000px) {
    .app {
        display: flex;
        overflow-x: auto;
        overflow-y: visible;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 24px;
        padding: 0 16px 40px 16px;
    }
    
    .sidebar-left,
    .feed,
    .sidebar-right {
        flex: 0 0 85vw;
        scroll-snap-align: start;
    }
    
    .sidebar-left,
    .sidebar-right {
        display: block;
    }
}

/* ---------- АДАПТИВНОСТЬ: ТЕЛЕФОН ---------- */
@media (max-width: 768px) {
    /* Шапка */
    .top-bar {
        padding: 12px 16px;
        margin-bottom: 20px;
    }
    .logo-text {
        display: none;
    }
    .top-avatar {
        position: static;
        top: 0;
    }
    .top-avatar-img {
        width: 48px;
        height: 48px;
        border-width: 2px;
    }
    .user-id-wrapper {
        display: none;
    }
    .chinese-char {
        font-size: 2.5rem;
    }
    
    /* Сетка — каждая колонка на весь экран */
    .app {
        display: flex;
        overflow-x: auto;
        overflow-y: visible;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        padding: 0;
        margin: 0;
    }
    
    .sidebar-left,
    .feed,
    .sidebar-right {
        flex: 0 0 100vw;
        scroll-snap-align: start;
        padding: 0 16px 40px 16px;
    }
    
    .sidebar-left,
    .sidebar-right {
        display: block;
    }
    
    .friends-section {
        height: calc(100vh - 160px);
    }
}

/* Форма поиска друга */
.friend-search-form {
    display: flex;
    gap: 8px;
}

/* Отключённый инпут */
input:disabled {
    background: #f5f0eb;
    color: var(--color-text-gray);
    cursor: not-allowed;
}
