/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --background: #0f0f23;
    --surface: #1a1a2e;
    --surface-light: #252547;
    --text: #ffffff;
    --text-muted: #a1a1aa;
    --border: #374151;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-light);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-muted);
    border: none;
}

.btn-icon:hover {
    color: var(--text);
}

/* Landing page styles */
.landing-page {
    min-height: 100vh;
    background: radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3), transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3), transparent 50%),
                radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.3), transparent 50%);
}

.navbar {
    padding: 1.5rem 2rem;
    background: rgba(15, 15, 35, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.hero-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
    min-height: calc(100vh - 100px);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
}

.hero-visual {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-preview {
    background: var(--surface);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
}

.chat-bubble {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    flex-shrink: 0;
}

.message {
    background: var(--surface-light);
    padding: 1rem;
    border-radius: 1rem;
    max-width: 300px;
}

.outgoing {
    flex-direction: row-reverse;
}

.outgoing .message {
    background: var(--primary);
}

.features-section {
    padding: 6rem 2rem;
    text-align: center;
    background: var(--surface);
}

.features-section h2 {
    font-size: 2.5rem;
    margin-bottom: 3rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.feature-card {
    background: var(--background);
    padding: 2.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-card i {
    font-size: 3rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.auth-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
}

.auth-header a {
    color: var(--primary);
    text-decoration: none;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    padding: 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.checkbox label {
    margin-bottom: 0;
}

.forgot-link {
    align-self: flex-end;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.auth-divider {
    text-align: center;
    margin: 2rem 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    background: var(--surface);
    padding: 0 1rem;
    color: var(--text-muted);
    position: relative;
}

.social-auth {
    display: flex;
    gap: 1rem;
}

.btn-social {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-google:hover {
    background: #db4437;
    color: white;
}

.btn-apple:hover {
    background: #000;
    color: white;
}

/* Chat page */
.chat-page {
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
}

.user-info {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.user-info .avatar {
    position: relative;
}

.user-info .avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

.user-details h3 {
    font-size: 1rem;
}

.user-details p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.sidebar-nav {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
    background: var(--background);
    color: var(--text);
}

.chat-list {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.chat-list h4 {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.chat-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.chat-item:hover,
.chat-item.active {
    background: var(--background);
}

.chat-info {
    flex: 1;
    position: relative;
}

.chat-info h5 {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.chat-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.unread {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-title h3 {
    font-size: 1rem;
}

.status {
    font-size: 0.875rem;
    color: var(--success);
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.message-date {
    text-align: center;
    color: var(--text-muted);
    margin: 1rem 0;
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: flex-end;
}

.message.incoming {
    align-self: flex-start;
}

.message.outgoing {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    max-width: 70%;
    background: var(--surface-light);
    padding: 0.75rem;
    border-radius: 1rem;
    position: relative;
}

.message.outgoing .message-content {
    background: var(--primary);
}

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

.message-content .time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.message.outgoing .time {
    color: rgba(255, 255, 255, 0.8);
}

.read {
    color: var(--success);
    margin-left: 0.25rem;
}

.chat-input {
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    border-top: 1px solid var(--border);
}

.input-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--surface);
    border-radius: 2rem;
    padding: 0.5rem 1rem;
}

.input-container input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 0.5rem;
}

.input-container input:focus {
    outline: none;
}

#backButton {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-section {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 2rem 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-large {
        width: 100%;
        max-width: 300px;
    }
    
    .auth-container {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 1.5rem;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        transition: left 0.3s ease;
        z-index: 1000;
        background: var(--surface);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .chat-main {
        width: 100%;
    }
    
    .chat-header {
        padding: 0.75rem;
    }
    
    .chat-messages {
        padding: 0.5rem;
    }
    
    .chat-input {
        padding: 0.75rem;
    }
    
    .input-container {
        padding: 0.5rem;
    }
    
    /* Touch-friendly buttons */
    .btn,
    .btn-social,
    .nav-item,
    .chat-item {
        min-height: 44px;
    }
    
    /* Improve form inputs */
    .form-group input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Fix gradient background on mobile */
    .landing-page {
        background: radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3), transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3), transparent 50%),
                    radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.3), transparent 50%),
                    var(--background);
    }
    
    /* Fix chat preview overflow */
    .chat-preview {
        max-width: 100%;
        margin: 0 1rem;
    }
    
    /* Fix navigation stacking */
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        width: 100%;
        justify-content: center;
    }
    
    /* Fix features grid on mobile */
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    #backButton {
        display: block;
    }
}

/* Tablet improvements */
@media (min-width: 769px) and (max-width: 1024px) {
    .hero-section {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 3rem 2rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
}

/* Improve form accessibility */
input[type="text"],
input[type="email"],
input[type="password"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Add backdrop for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}