@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --brand: #111111;
  --brand-gradient: linear-gradient(135deg, #111111, #444444);
  --black: #111;
  --white: #fff;
  --bg-color: #f0f4f8;
  --muted: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --inbound-bg: #ffffff;
  --inbound-stripe: #111111;
  --outbound-bg: #111111;
  --outbound-color: #ffffff;
  --max-width: 1400px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.08);
  --shadow-brand: 0 12px 24px rgba(17, 17, 17, 0.2);
}

* { box-sizing: border-box; }
html, body {
  height: 100%; height: -webkit-fill-available; margin: 0;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg-color); color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  height: 72px;
  background: var(--brand-gradient);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  box-shadow: var(--shadow-sm);
  color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: relative; z-index: 1001;
}
.app-header .brand { font-weight: 800; font-size: 20px; color: var(--white); letter-spacing: -0.5px; }
.user-actions { display: flex; align-items: center; gap: 16px; }
.user-name { font-weight: 600; color: var(--white); }

.hamburger-btn {
  background: transparent; border: none; color: var(--white);
  cursor: pointer; display: flex; align-items: center; padding: 6px;
  border-radius: 8px; transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.15); }

/* Profile Dropdown */
.profile-dropdown-container { position: relative; display: inline-block; }
.profile-btn {
  background: rgba(255, 255, 255, 0.15); border: 1px solid transparent;
  color: var(--white); cursor: pointer; display: flex; align-items: center;
  padding: 8px 14px; border-radius: var(--radius-md); transition: all 0.2s;
  font-family: inherit; font-size: 15px; outline: none; font-weight: 500;
}
.profile-btn:hover { background: rgba(255, 255, 255, 0.25); box-shadow: none; }
.profile-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--white); border: 1px solid var(--muted);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  min-width: 180px; display: none; flex-direction: column; z-index: 1000; overflow: hidden;
}
.profile-menu.open { display: flex; animation: slideDown 0.2s ease-out; }
.profile-menu-item {
  padding: 12px 18px; color: var(--text-primary); text-decoration: none;
  font-size: 15px; font-weight: 500; border-bottom: 1px solid #f8fafc; transition: all 0.2s;
}
.profile-menu-item:last-child { border-bottom: none; }
.profile-menu-item:hover { background: #f8fafc; color: var(--brand); padding-left: 22px; }

/* Hamburger Menu & Sidebar */
.side-menu {
  position: fixed; top: 0; left: -320px; width: 300px; height: 100vh;
  background: var(--white); z-index: 10000; transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column;
}
.side-menu.open { left: 0; }
.side-menu-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px; background: var(--brand-gradient); color: var(--white);
}
.side-menu-header h3 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.close-menu-btn { background: transparent; border: none; color: var(--white); font-size: 32px; cursor: pointer; line-height: 1; }
.side-menu-list { list-style: none; padding: 0; margin: 0; flex: 1; overflow-y: auto; }
.side-menu-list li { border-bottom: 1px solid #f1f5f9; }
.side-menu-list a {
  display: block; padding: 18px 24px; color: var(--text-primary);
  text-decoration: none; font-weight: 600; font-size: 16px; transition: all 0.2s;
}
.side-menu-list a:hover { background: #f8fafc; color: var(--brand); padding-left: 28px; }
.side-menu-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
  z-index: 9999; display: none; opacity: 0; transition: opacity 0.4s ease;
}
.side-menu-overlay.open { display: block; opacity: 1; }

/* Layout */
.chat-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%; height: -webkit-fill-available;
  overflow: hidden; display: flex; flex-direction: column;
}
.chat-page .app-header { flex-shrink: 0; }
.app-main {
  display: flex; height: calc(100vh - 72px); width: 100%; max-width: var(--max-width);
  margin: 0 auto; padding: 24px; gap: 24px;
}
.chat-page .app-main { flex: 1; height: auto; overflow: hidden; min-height: 0; }

/* Rooms Panel */
.rooms-panel {
  width: 320px; background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; overflow: hidden;
}
.rooms-header {
  padding: 20px 24px; font-weight: 800; font-size: 18px; color: var(--text-primary);
  border-bottom: 1px solid #f1f5f9; background: #fcfcfd;
}
.rooms-list { list-style: none; margin: 0; padding: 12px; flex: 1; overflow-y: auto; }
.room-item {
  padding: 14px 18px; margin-bottom: 8px; border-radius: var(--radius-md);
  cursor: pointer; display: flex; flex-direction: column; transition: all 0.2s;
  border: 1px solid transparent;
}
.room-item:hover { background: #f8fafc; border-color: #e2e8f0; }
.room-item[data-active="1"] {
  background: var(--brand-gradient); color: var(--white); box-shadow: var(--shadow-brand);
}
.room-item[data-active="1"] .room-type { color: rgba(255,255,255,0.8); }
.room-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.room-type { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* Chat panel */
.chat-panel {
  flex: 1; display: flex; flex-direction: column; min-height: 0; height: 100%;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden;
}
.chat-window {
  flex: 1; padding: 24px; overflow-y: auto; overflow-x: hidden;
  background: #fafbfc; min-height: 0;
}
.msg-form {
  display: flex; padding: 16px 24px; border-top: 1px solid #f1f5f9;
  background: var(--white); gap: 12px; align-items: center;
}
.msg-form input[type="text"] {
  flex: 1; padding: 16px 20px; border-radius: 30px; border: 1px solid var(--muted);
  font-size: 15px; font-family: inherit; font-weight: 500; outline: none;
  background: #f8fafc; transition: all 0.2s;
}
.msg-form input[type="text"]:focus { border-color: var(--brand); background: var(--white); box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.1); }
.send-btn {
  background: var(--brand-gradient); color: var(--white); padding: 16px 28px;
  border-radius: 30px; border: none; font-weight: 700; font-family: inherit;
  font-size: 15px; cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow-brand);
}
.send-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(17, 17, 17, 0.3); }
.send-btn:active { transform: translateY(0); }

/* Message styles & Roles */
.role-badge { display:inline-block; padding:3px 8px; border-radius:12px; font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:0.5px; vertical-align:middle; }
.role-kullanıcı { background:#e2e8f0; color:#475569; }
.role-mod { background:#dbeafe; color:#1e40af; }
.role-mod { background:#fef08a; color:#854d0e; }
.role-mod { background:#f3e8ff; color:#6b21a8; }
.role-yönetici { background:#fee2e2; color:#991b1b; }

.message {
  max-width: 75%; margin-bottom: 20px; padding: 14px 18px; border-radius: 20px;
  position: relative; word-break: break-word; line-height: 1.5; font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.message .meta { font-size: 12px; margin-bottom: 6px; font-weight: 600; opacity: 0.8; }
.inbound {
  background: var(--white); color: var(--text-primary); align-self: flex-start;
  border-bottom-left-radius: 4px; border: 1px solid var(--muted);
}
.outbound {
  background: var(--brand-gradient); color: var(--outbound-color);
  align-self: flex-end; border-bottom-right-radius: 4px; box-shadow: var(--shadow-brand);
}

/* Auth pages */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; height: 100dvh; background: var(--bg-color); }
.auth-card {
  width: 100%; max-width: 440px; padding: 40px; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); background: var(--white);
}
.auth-card h1 { margin: 0 0 24px; font-weight: 800; letter-spacing: -1px; }
.auth-form label { display: block; margin-bottom: 16px; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.auth-form input, .auth-form textarea {
  width: 100%; padding: 14px 16px; margin-top: 6px; border-radius: var(--radius-md);
  border: 1px solid var(--muted); background: #f8fafc; font-family: inherit; font-size: 15px;
  transition: all 0.2s; outline: none; resize: vertical;
}
.auth-form input:focus, .auth-form textarea:focus { border-color: var(--brand); background: var(--white); box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.1); }
.btn-primary {
  background: var(--brand-gradient); color: var(--white); padding: 14px 24px;
  border-radius: var(--radius-md); border: none; font-weight: 700; font-size: 15px;
  font-family: inherit; cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow-brand);
  display: inline-block; text-align: center; text-decoration: none;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(17, 17, 17, 0.3); }
.link { color: var(--brand); text-decoration: none; font-weight: 600; font-size: 14px; }
.link:hover { text-decoration: underline; }
.alert { padding: 14px 18px; border-radius: var(--radius-md); margin-bottom: 20px; font-weight: 500; font-size: 14px; }
.alert-error { background: #fff0f0; border: 1px solid #ffc2c2; color: #cc0000; }
.alert-success { background: #f0fff4; border: 1px solid #c6f6d5; color: #22543d; }

/* In-App Notifications (Toasts) */
.toast-container {
  position: fixed; top: 88px; right: 24px; z-index: 10000;
  display: flex; flex-direction: column; gap: 12px; pointer-events: none;
}
.toast-notification {
  background: var(--white); border-radius: var(--radius-md); padding: 16px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12); border-left: 4px solid var(--brand);
  width: 320px; pointer-events: auto; cursor: pointer;
  transform: translateX(120%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  opacity: 0;
}
.toast-notification.show { transform: translateX(0); opacity: 1; }
.toast-title { font-weight: 800; font-size: 15px; color: var(--text-primary); margin-bottom: 4px; }
.toast-body { font-size: 14px; color: var(--text-secondary); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* PWA install banner */
.pwa-install-banner {
  position: fixed; left: 24px; right: 24px; bottom: 24px; padding: 16px 24px;
  background: var(--white); border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-md); z-index: 9999; font-weight: 600;
}
.install-btn {
  background: var(--brand-gradient); color: var(--white); padding: 10px 18px;
  border-radius: var(--radius-md); border: none; font-weight: 700; font-family: inherit;
  cursor: pointer; box-shadow: var(--shadow-brand); transition: all 0.2s;
}

/* Animations */
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 900px) {
  .app-main { padding: 16px; gap: 16px; height: calc(100vh - 72px); }
  .rooms-panel { display: none; }
  .message { max-width: 85%; }
}
@media (max-width: 600px) {
  .app-main { padding: 12px; margin: 0; border-radius: 0; height: calc(100vh - 72px); }
  .chat-panel { border-radius: 0; box-shadow: none; border-top: 1px solid var(--muted); }
  .auth-card { padding: 32px 24px; margin: 16px; border-radius: var(--radius-lg); }
  .app-header { padding: 0 16px; }
  .toast-container { top: auto; bottom: 24px; left: 16px; right: 16px; }
  .toast-notification { width: 100%; }
}
