* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background: #1a1a1a;
    color: #ffffff;
}

.screen {
    display: none;
    height: 100vh;
}

.screen.active {
    display: block;
}

/* Auth Styles */
.auth-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #007aff, #5ac8fa);
}

.auth-header {
    text-align: center;
    margin-bottom: 40px;
}

.auth-header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: white;
}

.auth-header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1em;
}

.auth-form {
    width: 100%;
    max-width: 400px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group input {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    outline: none;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: #007aff;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 15px;
}

.btn-secondary {
    width: 100%;
    padding: 15px;
    background: transparent;
    color: white;
    border: 2px solid white;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}

/* Main App Styles */
.phone-mockup {
    width: 100vw;
    height: 100vh;
    background: #000000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #1c1c1e;
    border-bottom: 1px solid #38383a;
    height: 60px;
    display: none;
}

.header.active {
    display: flex;
}

.header h2 {
    font-size: 18px;
    font-weight: 600;
}

.icon {
    color: #8e8e93;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.content-wrapper {
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

.content-container {
    display: none;
    flex-direction: column;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.content-container.active {
    display: flex;
}

/* Stories */
.stories-container {
    padding: 15px;
    background: #1c1c1e;
    border-bottom: 1px solid #38383a;
    display: flex;
    gap: 15px;
    overflow-x: auto;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex-shrink: 0;
}

.story-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid transparent;
    background: linear-gradient(#2c2c2e, #2c2c2e) padding-box,
                linear-gradient(135deg, #007aff, #5ac8fa) border-box;
}

.story-photo {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007aff, #5ac8fa);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.story-plus {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #1c1c1e;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #38383a;
}

.story-name {
    font-size: 11px;
    color: #8e8e93;
    margin-top: 4px;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat List Tabs */
.chat-list-tabs {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: #1c1c1e;
    border-bottom: 1px solid #38383a;
}

.chat-list-tab {
    font-size: 14px;
    color: #8e8e93;
    font-weight: 500;
    cursor: pointer;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}

.chat-list-tab.active {
    color: #007aff;
    border-bottom-color: #007aff;
}

/* Search */
.search-input-container {
    padding: 15px;
    background: #1c1c1e;
    border-bottom: 1px solid #38383a;
}

.search-box {
    display: flex;
    align-items: center;
    background: #2c2c2e;
    border-radius: 10px;
    padding: 0 12px;
    border: 1px solid #38383a;
}

.search-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    padding: 12px 0;
    font-size: 16px;
}

.search-input::placeholder {
    color: #8e8e93;
}

/* Chat List */
.chat-list {
    flex-grow: 1;
    overflow-y: auto;
    list-style: none;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #38383a;
    cursor: pointer;
}

.chat-item-photo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007aff, #5ac8fa);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 15px;
}

.chat-item-info {
    flex-grow: 1;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.name {
    font-weight: 500;
}

.time {
    color: #8e8e93;
    font-size: 13px;
}

.chat-item-message p {
    color: #8e8e93;
    font-size: 14px;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #1c1c1e;
    border-bottom: 1px solid #38383a;
    height: 60px;
}

.chat-header-info {
    flex-grow: 1;
    text-align: center;
}

.chat-header-info h3 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-info span {
    color: #8e8e93;
    font-size: 13px;
}

/* Chat Content */
.chat-content {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #0c0c0d;
}

.chat-message-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 12px;
}

.chat-message-container.sent {
    align-items: flex-end;
}

.chat-message-container.received {
    align-items: flex-start;
}

.chat-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message-container.received .chat-message-bubble {
    background: #353537;
    border-bottom-left-radius: 4px;
}

.chat-message-container.sent .chat-message-bubble {
    background: linear-gradient(135deg, #007aff, #5ac8fa);
    border-bottom-right-radius: 4px;
    color: white;
}

.chat-message-time {
    font-size: 11px;
    color: #8e8e93;
    margin-top: 4px;
    text-align: right;
}

.chat-message-container.received .chat-message-time {
    text-align: left;
    padding-left: 40px; /* Выравниваем с текстом сообщения */
}

.chat-input-container {
    padding: 15px;
    background: #1c1c1e;
    border-top: 1px solid #38383a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-field {
    flex-grow: 1;
    background: #2c2c2e;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 16px;
    outline: none;
}

.chat-input-field::placeholder {
    color: #8e8e93;
}

/* Profile */
.profile-header {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #1c1c1e;
    border-bottom: 1px solid #38383a;
    gap: 15px;
}

.profile-pic {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #78909c, #607d8b);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 20px;
}

.profile-info h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 5px;
}

.profile-info p {
    color: #8e8e93;
    font-size: 14px;
}

.settings-section {
    list-style: none;
    background: #2c2c2e;
    margin: 10px 0;
    border-radius: 0;
}

.settings-list-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #38383a;
    cursor: pointer;
}

.settings-list-item:last-child {
    border-bottom: none;
}

.settings-list-item .icon {
    width: 24px;
    text-align: center;
    font-size: 18px;
    margin-right: 15px;
}

.profile-list-item-left h4 {
    font-weight: 500;
    margin-bottom: 2px;
}

.profile-list-item-left p {
    color: #8e8e93;
    font-size: 13px;
}

/* Sidebar */
.sidebar {
    background: #1c1c1e;
    width: 320px;
    max-width: 85%;
    position: absolute;
    top: 0;
    left: -320px;
    bottom: 0;
    transition: left 0.3s;
    z-index: 200;
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 199;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    background: #2c2c2e;
    border-bottom: 1px solid #38383a;
}

.sidebar-profile-pic {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #78909c, #607d8b);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 15px;
}

.sidebar-list {
    list-style: none;
}

.sidebar-list-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    gap: 20px;
    font-size: 16px;
    color: white;
    cursor: pointer;
    border-bottom: 1px solid #38383a;
}

.sidebar-list-item .icon {
    width: 24px;
    text-align: center;
    font-size: 18px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: #8e8e93;
}

/* Online status */
.status-online {
    color: #4cd964 !important;
}

.status-offline {
    color: #8e8e93 !important;
}

/* Добавляем в конец файла */

/* Стили для сообщений с аватарами */
.message-sender-info {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007aff, #5ac8fa);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 40px);
}

.sender-name {
    font-size: 12px;
    color: #8e8e93;
    margin-bottom: 4px;
    font-weight: 500;
}

.chat-message-container.received .chat-message-bubble {
    background: #353537;
    border-radius: 18px;
    color: white;
}

.chat-message-container.sent .chat-message-bubble {
    background: linear-gradient(135deg, #007aff, #5ac8fa);
    border-radius: 18px;
    color: white;
}

/* Убираем треугольники у сообщений для более современного вида */
.chat-message-container.received .chat-message-bubble,
.chat-message-container.sent .chat-message-bubble {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
}

/* Адаптивность для маленьких экранов */
@media (max-width: 480px) {
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    
    .sender-name {
        font-size: 11px;
    }
}

.send-button {
    background: none;
    border: none;
    color: #007aff;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.send-button:disabled {
    color: #8e8e93;
    cursor: not-allowed;
}

.send-button:not(:disabled):hover {
    background: rgba(0, 122, 255, 0.1);
}

/* Индикатор отправки */
.sending {
    opacity: 0.7;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #8e8e93;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007aff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: #ff3b30 !important;
}

/* Стиль для временных сообщений */
.chat-message-container .temp-message {
    opacity: 0.7;
}
/* Кнопка «Написать человеку» на главном экране */
.new-chat-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: calc(100% - 24px);
    margin: 12px;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #007aff, #5ac8fa);
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.new-chat-button:hover { opacity: 0.9; }
.new-chat-button:active { opacity: 0.8; }
.new-chat-button i { font-size: 18px; }
