/* =========================================================
   SecretChat - Stil Dosyası
   WhatsApp benzeri, mobil öncelikli, koyu/açık tema destekli
   ========================================================= */

:root {
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Koyu Tema (tek tema) ---------- */
:root {
    --bg: #0b141a;
    --panel: #111b21;
    --panel-2: #202c33;
    --header: #202c33;
    --text: #e9edef;
    --text-muted: #8696a0;
    --accent: #00a884;
    --accent-strong: #008f72;
    --bubble-out: #005c4b;
    --bubble-in: #202c33;
    --bubble-out-text: #e9edef;
    --bubble-in-text: #e9edef;
    --border: #2a3942;
    --input-bg: #2a3942;
    --shadow: rgba(0, 0, 0, 0.4);
    --danger: #f15c6d;
    --online-dot: #00d9a3;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
}

/* =========================================================
   EKRAN YÖNETİMİ
   ========================================================= */
.screen {
    display: none;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* =========================================================
   ANA EKRAN
   ========================================================= */
#screen-home {
    align-items: center;
    justify-content: center;
    background: #000000;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    position: relative;
}

.home-wrap {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 28px;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    max-width: 360px;
    width: 100%;
}

.brand-logo-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.brand h1 {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-tagline {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.home-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.big-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    border-radius: 14px;
    border: none;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, opacity 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
}

.big-btn:active {
    transform: scale(0.98);
}

.big-btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--shadow);
}

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

.big-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.big-btn-icon {
    font-size: 20px;
    line-height: 1;
}

.home-note {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

/* =========================================================
   FORM EKRANLARI (Oluştur / Katıl)
   ========================================================= */
.form-wrap {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--panel-2);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    align-self: flex-start;
}

.form-wrap h2 {
    margin: 4px 0 0;
}

.form-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}

#form-create, #form-join {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 8px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.field input {
    padding: 14px 44px 14px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.field input:focus {
    border-color: var(--accent);
}

.toggle-visibility {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
}

.field-hint {
    margin: -8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* =========================================================
   SOHBET EKRANI
   ========================================================= */
#screen-chat {
    background: var(--bg);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    padding-top: calc(10px + var(--safe-top));
    background: var(--header);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

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

.chat-title {
    font-weight: 600;
    font-size: 16px;
}

.chat-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-subtitle::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--online-dot);
}

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

.icon-btn:active {
    background: var(--panel-2);
}

/* ---------- Mesaj Listesi ---------- */
.message-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background-image:
        linear-gradient(var(--bg), var(--bg));
    background-color: var(--bg);
    -webkit-overflow-scrolling: touch;
}

.msg-row {
    display: flex;
    width: 100%;
}

.msg-row.out {
    justify-content: flex-end;
}

.msg-row.in {
    justify-content: flex-start;
}

.bubble {
    max-width: 78%;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14.5px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    box-shadow: 0 1px 1px var(--shadow);
}

.msg-row.out .bubble {
    background: var(--bubble-out);
    color: var(--bubble-out-text);
    border-top-right-radius: 2px;
}

.msg-row.in .bubble {
    background: var(--bubble-in);
    color: var(--bubble-in-text);
    border-top-left-radius: 2px;
}

.bubble .sender {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
}

.bubble .time {
    display: block;
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    margin-left: 8px;
    float: right;
}

.bubble img.chat-image {
    display: block;
    max-width: 100%;
    max-height: 260px;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    object-fit: cover;
}

.bubble.image-bubble {
    padding: 6px;
}

/* ---------- Sistem mesajları ---------- */
.system-msg {
    align-self: center;
    background: var(--panel-2);
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    margin: 6px auto;
    text-align: center;
}

/* ---------- Yazıyor göstergesi ---------- */
.typing-indicator {
    color: var(--accent);
    font-style: italic;
}

.typing-bar {
    padding: 4px 14px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    background: var(--bg);
}

/* ---------- Composer (mesaj giriş çubuğu) ---------- */
.composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    padding-bottom: calc(8px + var(--safe-bottom));
    background: var(--header);
    border-top: 1px solid var(--border);
    flex: 0 0 auto;
    position: relative;
}

.attach-wrap {
    position: relative;
    flex: 0 0 auto;
}

.attach-menu {
    position: absolute;
    bottom: 52px;
    left: 0;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 16px var(--shadow);
    display: flex;
    flex-direction: column;
    min-width: 180px;
    z-index: 20;
}

.attach-menu[hidden] {
    display: none;
}

.attach-menu-item {
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
}

.attach-menu-item:active {
    background: var(--bg);
}

#message-input {
    flex: 1 1 auto;
    resize: none;
    border: none;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 15px;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
}

.send-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

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

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================================
   RESİM GÖRÜNTÜLEYİCİ (TAM EKRAN)
   ========================================================= */
.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer[hidden] {
    display: none;
}

.image-viewer img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
}

.image-viewer-close {
    position: absolute;
    top: calc(12px + var(--safe-top));
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* =========================================================
   YÜKLENİYOR / TOAST
   ========================================================= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #fff;
    text-align: center;
    padding: 24px;
}

.loading-overlay[hidden] {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

#toast-container {
    position: fixed;
    top: calc(12px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(92vw, 420px);
    align-items: center;
}

.toast {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    box-shadow: 0 4px 16px var(--shadow);
    width: 100%;
    text-align: center;
    animation: toast-in 0.2s ease;
}

.toast.error {
    border-color: var(--danger);
    color: var(--danger);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   RESPONSIVE / MASAÜSTÜ
   ========================================================= */
@media (min-width: 720px) {
    #screen-chat {
        max-width: 720px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
