:root {
    --background-light: #f4f7fa; --surface-light: #ffffff; --primary-text-light: #111827; --secondary-text-light: #6b7280; --accent-light: #3b82f6; --accent-text-light: #ffffff; --sent-bubble-light: #3b82f6; --received-bubble-light: #e5e7eb; --error-light: #ef4444;
    --background-dark: #0d1117; --surface-dark: #161b22; --primary-text-dark: #f0f6fc; --secondary-text-dark: #8b949e; --accent-dark: #58a6ff; --accent-text-dark: #0d1117; --sent-bubble-dark: #238636; --received-bubble-dark: #21262d; --error-dark: #f87171;
    --font-family: 'Inter', sans-serif; --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); --radius: 0.75rem;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body { font-family: var(--font-family); height: 100%; width: 100%; overflow: hidden; transition: background-color 0.3s, color 0.3s; -webkit-tap-highlight-color: transparent; }
body.light-mode { --bg: var(--background-light); --surface: var(--surface-light); --text-primary: var(--primary-text-light); --text-secondary: var(--secondary-text-light); --accent: var(--accent-light); --accent-text: var(--accent-text-light); --sent-bubble: var(--sent-bubble-light); --received-bubble: var(--received-bubble-light); --error: var(--error-light); }
body.dark-mode { --bg: var(--background-dark); --surface: var(--surface-dark); --text-primary: var(--primary-text-dark); --text-secondary: var(--secondary-text-dark); --accent: var(--accent-dark); --accent-text: var(--accent-text-dark); --sent-bubble: var(--sent-bubble-dark); --received-bubble: var(--received-bubble-dark); --error: var(--error-dark); }

#app { display: flex; flex-direction: column; height: 100vh; width: 100%; background-color: var(--bg); color: var(--text-primary); }
.loading-container, .auth-container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; padding: 2rem; text-align: center; }
.spinner { width: 48px; height: 48px; border: 5px solid var(--received-bubble); border-bottom-color: var(--accent); border-radius: 50%; display: inline-block; box-sizing: border-box; animation: rotation 1s linear infinite; }
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.app-view { display: flex; flex-direction: column; height: 100%; position: relative; overflow: hidden; }
.auth-box { width: 100%; max-width: 380px; background-color: var(--surface); padding: 2.5rem; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.auth-box h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.auth-box p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.auth-box input { width: 100%; padding: 0.75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--received-bubble); border-radius: 0.5rem; background: var(--bg); color: var(--text-primary); font-size: 1rem; }
.btn { width: 100%; padding: 0.75rem 1rem; border: none; border-radius: 0.5rem; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s, opacity 0.2s; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-primary { background-color: var(--accent); color: var(--accent-text); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 0.75rem; background-color: #4285F4; color: white; margin-bottom: 1rem; }
#error-message { color: var(--error); min-height: 1.5rem; margin-top: 1rem; }

.panel { position: fixed; top: 0; bottom: 0; width: 85%; max-width: 380px; background-color: var(--surface); z-index: 1000; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform 0.3s ease-in-out; }
#chat-list-panel { left: 0; transform: translateX(-105%); }
#settings-panel { right: 0; transform: translateX(105%); }
body.panel-open #chat-list-panel, body.panel-open #settings-panel { transform: translateX(0); }
.panel-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999; opacity: 0; transition: opacity 0.3s ease-in-out; pointer-events: none; }
body.panel-open .panel-overlay { opacity: 1; pointer-events: auto; }

.app-header { display: flex; align-items: center; padding: 0.75rem 1rem; background-color: var(--surface); box-shadow: var(--shadow); z-index: 10; gap: 0.75rem; flex-shrink: 0; }
.profile-pic { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background-color: var(--received-bubble); flex-shrink: 0;}
.chat-info { flex-grow: 1; text-align: center; }
.chat-info h3 { font-size: 1.1rem; } .chat-info small { font-size: 0.8rem; color: #22c55e; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 0.5rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; }
.icon-btn:hover { background-color: var(--received-bubble); }

#chat-messages { flex-grow: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.message { display: flex; max-width: 80%; gap: 0.5rem; position: relative; }
.message-content { display: flex; flex-direction: column; gap: 0.25rem; width: 100%;}
.message .bubble { padding: 0.75rem 1rem; border-radius: 1.25rem; word-wrap: break-word; width: fit-content; position: relative; }
.message.sent { align-self: flex-end; flex-direction: row-reverse; }
.message.sent .message-content { align-items: flex-end; }
.message.sent .bubble { background-color: var(--sent-bubble); color: var(--accent-text); border-bottom-right-radius: 0.25rem; }
.message.received { align-self: flex-start; }
.message.received .message-content { align-items: flex-start; }
.message.received .bubble { background-color: var(--received-bubble); color: var(--text-primary); border-bottom-left-radius: 0.25rem; }
.message.status-failed .bubble { background-color: var(--error) !important; color: var(--accent-text) !important; }
.message .timestamp { font-size: 0.75rem; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.message .status-icon { font-size: 1rem; }
.message .status-icon.read { color: var(--accent); }

.chat-input-area { display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem; background-color: var(--surface); border-top: 1px solid var(--received-bubble); }
.input-row { display: flex; align-items: flex-end; gap: 0.5rem; }
#text-input { flex-grow: 1; border: none; background-color: var(--received-bubble); color: var(--text-primary); padding: 0.75rem 1.25rem; border-radius: 2rem; font-size: 1rem; outline: none; resize: none; max-height: 120px; }
#send-btn { height: 44px; width: 44px; flex-shrink: 0; }

#chat-list-panel .panel-header, #settings-panel .panel-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--received-bubble); display: flex; align-items: center; justify-content: space-between; }
#chat-list-panel h2, #settings-panel h3 { font-size: 1.25rem; }
#chat-list { flex-grow: 1; overflow-y: auto; }
#chat-list-panel .search-container { padding: 1rem; border-bottom: 1px solid var(--received-bubble); }
#chat-list-panel .search-container input { width:100%; padding:0.75rem; border-radius: 0.5rem; border: 1px solid var(--received-bubble); background: var(--bg); color: var(--text-primary);}
.chat-list-item { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; cursor: pointer; border-bottom: 1px solid var(--received-bubble); }
.chat-list-item:hover { background-color: var(--received-bubble); }
.chat-list-item .profile-pic-container { position: relative; flex-shrink: 0; }
.online-indicator { width: 12px; height: 12px; border-radius: 50%; background-color: var(--text-secondary); position: absolute; bottom: 0; right: 0; border: 2px solid var(--surface); }
.online-indicator.online { background-color: #22c55e; }

#settings-panel .settings-content { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
#settings-panel h4 { margin-bottom: -0.5rem; }

#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast { background-color: #333; color: white; padding: 12px 20px; border-radius: 25px; font-size: 0.9rem; box-shadow: 0 3px 10px rgba(0,0,0,0.2); opacity: 0; transform: translateY(20px); transition: opacity 0.3s, transform 0.3s; }
.toast.show { opacity: 1; transform: translateY(0); }