* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: calc(100vh - env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

.likes-count {
    font-size: 1rem;
    background: rgba(255,255,255,0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Sections */
.section {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.section.active {
    display: flex;
}

#discoverSection {
    justify-content: center;
    padding: 2rem;
}

#matchesSection {
    padding: 1rem;
    overflow-y: auto;
}

#profileSection {
    padding: 2rem;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
}

/* Card Stack */
.card-stack {
    position: relative;
    width: 100%;
    height: 500px;
    margin-bottom: 2rem;
}

.card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    cursor: grab;
    user-select: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.card:active {
    cursor: grabbing;
}

.card-image {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
}

.photo-indicators {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 2;
}

.photo-indicator {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    transition: background 0.3s ease;
}

.photo-indicator.active {
    background: rgba(255, 255, 255, 0.9);
}

.card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    color: white;
    z-index: 1;
}

.card-name {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 0.3rem;
}

.card-details {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.card-bio {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

/* Actions */
.actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.action-btn:hover {
    transform: scale(1.1);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn .icon {
    font-size: 1.8rem;
}

.dislike {
    background: #fff;
    color: #ff6b6b;
}

.super-like {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 70px;
    height: 70px;
}

.like {
    background: #fff;
    color: #51cf66;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 1rem;
    background: white;
    border-top: 1px solid #e9ecef;
}

/* Mobile browser compatibility */
@media (max-width: 768px) {
    .bottom-nav {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 1rem));
        padding-bottom: calc(1rem + constant(safe-area-inset-bottom, 1rem)); /* iOS < 11.2 */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    /* Additional padding for mobile browsers */
    .app {
        height: 100vh;
        padding-bottom: 0;
    }
    
    /* Add space for bottom nav in main content */
    .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
        padding-bottom: calc(80px + constant(safe-area-inset-bottom, 20px)); /* iOS < 11.2 */
    }
    
    /* Ensure action buttons are visible */
    .actions {
        margin-bottom: calc(90px + env(safe-area-inset-bottom, 20px));
        margin-bottom: calc(90px + constant(safe-area-inset-bottom, 20px)); /* iOS < 11.2 */
    }
    
    /* Prevent viewport issues */
    html {
        height: 100%;
        overflow-x: hidden;
    }
    
    body {
        padding-bottom: 0;
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #adb5bd;
    transition: color 0.2s ease;
}

.nav-item.active {
    color: #667eea;
}

.nav-item .icon {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
}

.nav-item .label {
    font-size: 0.75rem;
}

/* Swipe indicators */
.card.swipe-left {
    transform: translateX(-100%) rotate(-20deg);
    opacity: 0;
}

.card.swipe-right {
    transform: translateX(100%) rotate(20deg);
    opacity: 0;
}

.card.swipe-up {
    transform: translateY(-100%) rotate(-10deg);
    opacity: 0;
}

.card.swipe-down {
    transform: translateY(100%) rotate(10deg);
    opacity: 0;
}

/* Loading state */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
}

/* Chats List */
.chats-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chat-item:hover {
    background: #f8f9fa;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 1rem;
    flex-shrink: 0;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: #333;
}

.chat-last-message {
    font-size: 0.9rem;
    color: #868e96;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.75rem;
    color: #adb5bd;
    flex-shrink: 0;
}

/* Chat View */
#chatSection {
    background: #f8f9fa;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

.back-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
}

.chat-partner-info {
    font-weight: bold;
    font-size: 1.1rem;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-content {
    margin-bottom: 0.25rem;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
}

.message-input-container {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: white;
    border-top: 1px solid #e9ecef;
}

#messageInput {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    font-size: 1rem;
    outline: none;
}

#messageInput:focus {
    border-color: #667eea;
}

#sendMessageBtn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: bold;
}

#sendMessageBtn:active {
    transform: scale(0.95);
}

/* Typing Indicator */
.typing-indicator {
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Profile */
.profile-info {
    text-align: center;
    padding: 2rem;
}

.btn-primary {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    margin-top: 1rem;
}

/* Telegram Auth Button */
.telegram-auth-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.btn-telegram {
    background: linear-gradient(135deg, #0088cc 0%, #229ED9 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
    transition: all 0.3s ease;
}

.btn-telegram:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.4);
}

.btn-telegram:active {
    transform: translateY(0);
}

.telegram-icon {
    font-size: 18px;
}

.auth-text {
    white-space: nowrap;
}

/* Telegram Auth Modal */
.telegram-auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.telegram-auth-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.telegram-logo {
    font-size: 48px;
    margin-bottom: 20px;
}

.telegram-auth-content h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 24px;
}

.telegram-auth-content p {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.5;
}

.auth-steps {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.auth-steps .step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.auth-steps .step-number {
    width: 30px;
    height: 30px;
    background: #0088cc;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.auth-steps .step-text {
    color: #333;
    font-size: 16px;
    font-weight: 500;
}

.auth-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Onboarding Modal */
.onboarding-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.onboarding-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.onboarding-content h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 24px;
}

.onboarding-content p {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
}

.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.step-number {
    width: 30px;
    height: 30px;
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.step-text {
    color: #333;
    font-size: 16px;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 500px) {
    .app {
        max-width: 100%;
        border-radius: 0;
    }
    
    #discoverSection {
        padding: 1rem;
    }
    
    .onboarding-content {
        padding: 20px;
        max-width: 350px;
    }
    
    .onboarding-content h2 {
        font-size: 20px;
    }
    
    .onboarding-content p {
        font-size: 14px;
    }
    
    .step {
        padding: 12px;
    }
    
    .step-number {
        width: 25px;
        height: 25px;
        font-size: 12px;
    }
    
    .step-text {
        font-size: 14px;
    }
}

