/**
 * IndoChat Stylesheet
 * Modern WhatsApp + Telegram style
 */

/* Variables */
:root {
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --bg-chat: #efeae2;
    --bg-bubble-out: #dcf8c6;
    --bg-bubble-in: #ffffff;
    --text-primary: #111111;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --accent-color: #00a884;
    --accent-hover: #008f72;
    --danger-color: #e53935;
    --online-color: #4caf50;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --bg-primary: #111b21;
    --bg-secondary: #1f2c33;
    --bg-tertiary: #2a3942;
    --bg-chat: #0b141a;
    --bg-bubble-out: #005c4b;
    --bg-bubble-in: #202c33;
    --text-primary: #e9edef;
    --text-secondary: #aebac1;
    --text-muted: #8696a0;
    --border-color: #2a3942;
    --accent-color: #00a884;
    --accent-hover: #06cf9c;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input, textarea, button {
    font-size: 14px;
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #128c7e 100%);
}

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

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo h1 {
    font-size: 32px;
    color: var(--accent-color);
    font-weight: 700;
}

.auth-logo p {
    color: var(--text-secondary);
    margin-top: 8px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s;
    position: relative;
}

.auth-tab.active {
    color: var(--accent-color);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-color);
}

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

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    width: 100%;
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

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

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

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

/* Main App Layout */
.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
}

/* Sidebar */
.sidebar {
    width: 400px;
    min-width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

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

.sidebar-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.sidebar-header .username {
    font-weight: 600;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.nav-tab {
    flex: 1;
    padding: 14px 8px;
    text-align: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    position: relative;
    transition: all 0.3s;
}

.nav-tab.active {
    color: var(--accent-color);
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--accent-color);
    border-radius: 3px 3px 0 0;
}

.nav-tab .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent-color);
    color: white;
    font-size: 11px;
    border-radius: 9px;
    margin-left: 4px;
}

/* Search */
.search-box {
    padding: 12px 16px;
    background: var(--bg-secondary);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
}

.search-input-wrapper svg {
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-input-wrapper input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
}

.search-input-wrapper input:focus {
    outline: none;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:hover {
    background: var(--bg-secondary);
}

.chat-item.active {
    background: var(--bg-tertiary);
}

.chat-item .avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.chat-item .chat-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-item .chat-preview {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item .chat-meta {
    text-align: right;
    flex-shrink: 0;
}

.chat-item .chat-time {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-item .unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    margin-top: 4px;
}

.online-indicator {
    width: 10px;
    height: 10px;
    background: var(--online-color);
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    position: absolute;
    bottom: 2px;
    right: 2px;
}

.avatar-wrapper {
    position: relative;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
}

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

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

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

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

.chat-header .header-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-header .header-actions {
    display: flex;
    gap: 8px;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
}

.message.sent {
    align-self: flex-end;
    background: var(--bg-bubble-out);
    border-radius: 8px 0 8px 8px;
}

.message.received {
    align-self: flex-start;
    background: var(--bg-bubble-in);
    border-radius: 0 8px 8px 8px;
    box-shadow: var(--shadow);
}

.message .sender-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.message .message-text {
    color: var(--text-primary);
    line-height: 1.4;
}

.message .message-time {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

.message .message-image {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 4px;
}

.message .message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 4px;
}

.message .message-file svg {
    width: 32px;
    height: 32px;
    color: var(--accent-color);
}

.message .message-file .file-info {
    flex: 1;
}

.message .message-file .file-name {
    font-weight: 500;
    font-size: 13px;
}

.message .message-file .file-size {
    font-size: 11px;
    color: var(--text-muted);
}

.message audio {
    width: 100%;
    min-width: 200px;
}

.date-separator {
    text-align: center;
    margin: 16px 0;
}

.date-separator span {
    background: var(--bg-tertiary);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

/* Message Input */
.message-input-area {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.message-input-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--bg-primary);
    border-radius: 24px;
    padding: 4px 16px;
    border: 1px solid var(--border-color);
}

.message-input-wrapper textarea {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

.message-input-wrapper textarea:focus {
    outline: none;
}

.input-actions {
    display: flex;
    gap: 4px;
    padding-bottom: 4px;
}

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--accent-color);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn svg {
    width: 22px;
    height: 22px;
}

/* Voice Recording */
.voice-recording {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.voice-recording .recording-indicator {
    width: 12px;
    height: 12px;
    background: var(--danger-color);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.voice-recording .recording-time {
    font-family: monospace;
    font-size: 16px;
}

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

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 18px;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-color);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 100;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Profile Panel */
.profile-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.profile-panel.active {
    right: 0;
}

.profile-panel-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--accent-color);
    color: white;
}

.profile-panel-header h3 {
    flex: 1;
}

.profile-panel-body {
    flex: 1;
    overflow-y: auto;
}

.profile-photo-section {
    padding: 30px;
    text-align: center;
    background: var(--bg-secondary);
}

.profile-photo-section .avatar-large {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
}

.profile-photo-section .upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
}

.profile-info-section {
    padding: 20px;
}

.profile-info-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.profile-info-item label {
    display: block;
    font-size: 12px;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.profile-info-item p {
    color: var(--text-primary);
}

/* Group/Channel Info Panel */
.info-panel-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.info-panel-section h4 {
    font-size: 14px;
    color: var(--accent-color);
    margin-bottom: 12px;
}

.member-list {
    max-height: 300px;
    overflow-y: auto;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

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

.member-item .member-info {
    flex: 1;
}

.member-item .member-name {
    font-weight: 500;
}

.member-item .member-role {
    font-size: 12px;
    color: var(--accent-color);
}

/* Channel Post */
.channel-post {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.channel-post .post-content {
    margin-bottom: 12px;
    line-height: 1.5;
}

.channel-post .post-image {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
}

.channel-post .post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.channel-post .post-meta svg {
    width: 16px;
    height: 16px;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--accent-color);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 100;
}

.fab:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
}

.toast {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin-top: 8px;
    animation: slideUp 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--online-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 100;
    }
    
    .sidebar.hidden {
        display: none;
    }
    
    .chat-area {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    .chat-area.hidden {
        display: none;
    }
    
    .chat-header .back-btn {
        display: flex;
    }
    
    .profile-panel {
        width: 100%;
        right: -100%;
    }
    
    .message {
        max-width: 85%;
    }
}

@media (min-width: 769px) {
    .chat-header .back-btn {
        display: none;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
}

.theme-toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.theme-toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

[data-theme="dark"] .theme-toggle-switch {
    background: var(--accent-color);
}

[data-theme="dark"] .theme-toggle-switch::after {
    transform: translateX(20px);
}

/* File input hidden */
.file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* Context Menu / Action Sheet */
.action-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-radius: 16px 16px 0 0;
    padding: 16px;
    transform: translateY(100%);
    transition: transform 0.3s;
    z-index: 1001;
}

.action-sheet.active {
    transform: translateY(0);
}

.action-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
}

.action-sheet-item:hover {
    background: var(--bg-secondary);
}

.action-sheet-item svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.action-sheet-cancel {
    margin-top: 8px;
    text-align: center;
    padding: 16px;
    color: var(--danger-color);
    font-weight: 500;
    cursor: pointer;
}
