/* ============================================
   AMEBO v2.0 - Styles
   ============================================ */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s ease;
}

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

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

/* ============================================
   Layout
   ============================================ */

#app {
    max-width: 500px;
    margin: 0 auto;
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Authentication
   ============================================ */

.auth-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

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

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

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    margin-bottom: -2px;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
}

/* ============================================
   Forms
   ============================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-secondary:hover {
    opacity: 0.9;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

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

.btn-icon.btn-primary:hover {
    background: var(--primary-dark);
}

/* ============================================
   Rooms View
   ============================================ */

.rooms-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.rooms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.rooms-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-container {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

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

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}

.search-results.show {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-weight: 500;
}

.search-result-username {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.rooms-list {
    flex: 1;
    overflow-y: auto;
}

.room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.room-item:hover {
    background: var(--bg-tertiary);
}

.room-info {
    flex: 1;
}

.room-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.room-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.room-delete {
    opacity: 0;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    border: none;
    background: var(--error);
    color: white;
    border-radius: var(--radius);
    cursor: pointer;
}

.room-item:hover .room-delete {
    opacity: 1;
}

/* ============================================
   Chat View
   ============================================ */

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

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-weight: 600;
}

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

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
}

.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    max-width: 80%;
}

.message-mine {
    align-self: flex-end;
    align-items: flex-end;
}

.message-theirs {
    align-self: flex-start;
    align-items: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-mine .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-theirs .message-content {
    background: white;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
}

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

/* ============================================
   Common Components
   ============================================ */

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

.badge {
    background: var(--error);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state p {
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state small {
    color: var(--text-muted);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Toast Notifications
   ============================================ */

#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--error);
}

.toast-warning {
    background: var(--warning);
}

.toast-info {
    background: var(--primary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 500px) {
    #app {
        max-width: 100%;
        box-shadow: none;
    }
}
