/* ============================================================
   Harun Otomasyon Paneli - Mobil öncelikli arayüz
   ============================================================ */

:root {
    --bg: #090c12;
    --bg-soft: #111722;
    --card: #141b27;
    --card-2: #1a2331;
    --border: rgba(148,163,184,.16);
    --text: #f3f6fb;
    --text-dim: #94a3b8;
    --primary: #635bff;
    --primary-2: #8b83ff;
    --accent: #e1306c;       /* instagram pembe */
    --accent-2: #f77737;
    --green: #2ecc71;
    --red: #ff5468;
    --blue: #3aa0ff;
    --gray: #7a8290;
    --radius: 16px;
    --shadow: 0 18px 55px rgba(0,0,0,.28);
    --shadow-sm: 0 8px 24px rgba(0,0,0,.18);
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: #aaa5ff; text-decoration: none; transition: color .2s; }
a:hover { color: #d4d1ff; }
img, video { max-width: 100%; display: block; }
.icon { width: 1.15em; height: 1.15em; display: inline-block; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; }

/* ---- Tipografi / yardımcı ---- */
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* ---- Butonlar ---- */
.btn {
    appearance: none;
    border: none;
    border-radius: 11px;
    padding: 13px 17px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #635bff, #7c74ff);
    cursor: pointer;
    width: 100%;
    transition: transform .15s ease, opacity .2s, box-shadow .2s, border-color .2s;
    box-shadow: 0 8px 22px rgba(99,91,255,.22);
}
.btn .icon { margin-right: 7px; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 11px 28px rgba(99,91,255,.3); }
.btn:active { transform: translateY(0) scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: linear-gradient(135deg, #ff5468, #c0392b); }
.btn.success { background: linear-gradient(135deg, #2ecc71, #1e9e57); }
.btn.ghost { background: rgba(255,255,255,.02); border: 1px solid var(--border); color: var(--text-dim); box-shadow: none; }
.btn.ghost:hover { color: var(--text); border-color: rgba(148,163,184,.35); box-shadow: none; }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }

/* ---- Form ---- */
label { display: block; font-size: 12px; font-weight: 650; color: #aab6c8; margin: 15px 0 7px; letter-spacing: .01em; }
input, select, textarea {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 11px;
    padding: 13px 14px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
input::placeholder, textarea::placeholder { color: #657186; }
input:hover, select:hover, textarea:hover { border-color: rgba(148,163,184,.28); }
input:focus, select:focus, textarea:focus { outline: none; border-color: #7c74ff; box-shadow: 0 0 0 4px rgba(99,91,255,.12); background: #131a25; }
input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.ai-provider-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.ai-provider-switch button { position: relative; display: flex; align-items: center; gap: 10px; min-height: 74px; padding: 13px; text-align: left; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 13px; cursor: pointer; }
.ai-provider-switch button:hover { border-color: rgba(139,124,255,.6); }
.ai-provider-switch button.active { border-color: var(--primary-2); background: rgba(109,93,252,.12); box-shadow: 0 0 0 1px rgba(109,93,252,.2) inset; }
.ai-provider-switch b, .ai-provider-switch small { display: block; }
.ai-provider-switch small { color: var(--text-dim); font-size: 11px; margin-top: 3px; line-height: 1.3; }
.ai-provider-icon { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; background: var(--card-2); }
.ai-check { position: absolute; top: 7px; right: 9px; color: var(--primary-2); opacity: 0; font-weight: 800; }
.ai-check .icon { width: 15px; height: 15px; stroke-width: 2.5; }
.ai-provider-switch button.active .ai-check { opacity: 1; }
.ai-key-panel { margin-top: 16px; padding: 15px; border-radius: 13px; border: 1px solid var(--border); background: var(--bg-soft); }
.ai-key-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ai-key-panel p { margin: 7px 0 2px; line-height: 1.5; }
.ai-key-panel .ai-clear { margin-top: 10px; cursor: pointer; }

/* ---- Kart ---- */
.card {
    background: linear-gradient(180deg, rgba(22,30,43,.97), rgba(18,25,36,.97));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 19px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 10px; font-size: 17px; letter-spacing: -.02em; }

/* ============================================================
   GİRİŞ EKRANI
   ============================================================ */
.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh; /* destekleyen tarayıcılarda dinamik yükseklik */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 600px at 75% -15%, rgba(99,91,255,.2), transparent 58%),
        radial-gradient(700px 500px at -10% 110%, rgba(51,166,255,.1), transparent 60%),
        var(--bg);
}
.auth-card { width: 100%; max-width: 410px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo {
    width: 64px; height: 64px; margin: 0 auto 12px;
    border-radius: 18px;
    display: grid; place-items: center;
    font-size: 30px;
    background: linear-gradient(145deg, #7c74ff, #4f46e5);
    box-shadow: 0 14px 35px rgba(99,91,255,.28), inset 0 1px rgba(255,255,255,.25);
}
.brand .logo .icon { width: 30px; height: 30px; }
.brand h1 { font-size: 22px; letter-spacing: -.035em; margin: 0; }
.brand p { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }

.alert {
    border-radius: 10px; padding: 11px 13px; font-size: 13px; margin-top: 12px;
    border: 1px solid transparent;
}
.alert.error { background: rgba(255,84,104,.12); border-color: rgba(255,84,104,.4); color: #ffb3bd; }
.alert.info  { background: rgba(58,160,255,.12); border-color: rgba(58,160,255,.4); color: #bfe0ff; }
.alert.ok    { background: rgba(46,204,113,.12); border-color: rgba(46,204,113,.4); color: #b6f0cf; }
.code-box { font-family: monospace; font-size: 18px; letter-spacing: 2px; background: var(--bg-soft); padding: 8px 12px; border-radius: 8px; display: inline-block; }
.auth-card-head { margin-bottom: 18px; }
.auth-card-head h3 { font-size: 21px; margin: 3px 0 5px; }
.auth-card-head p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.eyebrow { color: #9d97ff; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.success-text { color: #6ee7a8; }
.text-btn { display: block; margin: 14px auto 0; border: 0; background: transparent; color: #aaa5ff; font: inherit; font-size: 13px; cursor: pointer; padding: 5px 10px; }
.text-btn:hover { color: #d4d1ff; }
.otp-input { letter-spacing: 9px; text-align: center; font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.security-step { display: flex; align-items: center; gap: 11px; padding: 11px; margin-bottom: 13px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.02); }
.security-step > span { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(99,91,255,.16); color: #aaa5ff; font-weight: 800; }
.security-step b, .security-step small { display: block; }
.security-step b { font-size: 13px; }.security-step small { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.approval-visual { position: relative; width: 92px; height: 92px; margin: 22px auto; display: grid; place-items: center; }
.telegram-orb { position: relative; z-index: 2; width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(145deg,#38bdf8,#168bd2); color: white; font-size: 25px; transform: rotate(-18deg); box-shadow: 0 12px 30px rgba(56,189,248,.25); }
.approval-pulse { position: absolute; inset: 6px; border: 1px solid rgba(56,189,248,.45); border-radius: 28px; animation: approvalPulse 1.8s infinite; }
@keyframes approvalPulse { 0%{transform:scale(.72);opacity:.8} 100%{transform:scale(1.25);opacity:0} }
.status-line { display: flex; justify-content: center; align-items: center; gap: 9px; color: var(--text-dim); font-size: 13px; }

/* ============================================================
   PANEL
   ============================================================ */
.app-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top)); /* çentikli ekranlar */
    background: rgba(9,12,18,.78);
    backdrop-filter: blur(18px) saturate(130%);
    border-bottom: 1px solid var(--border);
}
.app-header .logo-sm {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px;
    background: linear-gradient(135deg, var(--accent-2), var(--accent), var(--primary));
}
.app-header .logo-sm .icon { width: 19px; height: 19px; }
.app-header h1 { font-size: 15px; letter-spacing: -.015em; margin: 0; }
.app-header .ig-pill {
    margin-left: auto; font-size: 12px; color: var(--text-dim);
    border: 1px solid var(--border); padding: 5px 9px; border-radius: 999px; white-space: nowrap;
}
.ig-pill .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gray); margin-right: 5px; }
.ig-pill.active .dot { background: var(--green); }

main.content {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px 100px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 24px; font-weight: 780; letter-spacing: -.035em; margin: 7px 0 18px; }

/* ---- Alt navigasyon ---- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex;
    background: rgba(14,19,28,.88);
    backdrop-filter: blur(18px) saturate(130%);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav button {
    flex: 1; background: none; border: none; color: var(--text-dim);
    font-size: 11px; padding: 6px 2px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottom-nav button .ico { line-height: 1; }
.bottom-nav button .ico .icon { width: 20px; height: 20px; stroke-width: 1.7; }
.bottom-nav button.active { color: var(--primary-2); }
.bottom-nav button { transition: color .2s, transform .2s; }
.bottom-nav button:hover { color: var(--text); transform: translateY(-1px); }

/* ---- İstatistik kutuları ---- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
    background: linear-gradient(145deg, rgba(25,34,48,.98), rgba(17,23,34,.98)); border: 1px solid var(--border); border-radius: 14px; padding: 17px; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 24px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---- Rozet ---- */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; display: inline-block; }
.badge.green { background: rgba(46,204,113,.16); color: #6ee7a8; }
.badge.red   { background: rgba(255,84,104,.16); color: #ff9aa6; }
.badge.blue  { background: rgba(58,160,255,.16); color: #9ccbff; }
.badge.gray  { background: rgba(122,130,144,.18); color: #c0c7d2; }

.type-chip { font-size: 11px; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* ---- Emir listesi ---- */
.order-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 13px; margin-bottom: 10px; box-shadow: 0 5px 18px rgba(0,0,0,.12); transition: transform .2s, border-color .2s;
}
.order-item:hover { transform: translateY(-1px); border-color: rgba(148,163,184,.28); }
.order-thumb {
    width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--bg-soft);
    display: grid; place-items: center; font-size: 20px; color: var(--text-dim);
}
.order-thumb .icon { width: 22px; height: 22px; }
.order-main { flex: 1; min-width: 0; }
.order-main .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-main .s { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.icon-btn {
    background: var(--card-2); border: 1px solid var(--border); color: var(--text);
    width: 38px; height: 38px; border-radius: 10px; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { transform: scale(.95); }

/* ---- Kütüphane galerisi ---- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gallery .g-item { position: relative; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; aspect-ratio: 1; background: var(--bg-soft); transition: border-color .15s, box-shadow .15s; }
.gallery .g-item.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,93,252,.35); }
.gallery .g-item img, .gallery .g-item video { width: 100%; height: 100%; object-fit: cover; }
.gallery .g-item .used { position: absolute; top: 4px; left: 4px; background: rgba(255,84,104,.9); color: #fff; font-size: 9px; padding: 2px 5px; border-radius: 6px; }
.gallery .g-item .vid { position: absolute; bottom: 4px; left: 4px; font-size: 12px; }
.gallery .g-item .vid .icon { width: 15px; height: 15px; padding: 2px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; }
.gallery .g-item .g-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); border: none; color: #fff; width: 26px; height: 26px; border-radius: 8px; font-size: 13px; cursor: pointer; display: grid; place-items: center; }
.gallery .g-item .g-del:active { transform: scale(.9); background: var(--red); }
.gallery .g-item .g-del .icon { width: 14px; height: 14px; }

/* ---- Başlıkta çıkış ---- */
.header-logout { margin-left: 8px; background: var(--card-2); border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer; flex-shrink: 0; }
.header-logout:active { transform: scale(.95); }
.header-logout .icon { width: 17px; height: 17px; }

/* ---- Gizli dosya girişi (label ile tetiklenir) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.upload-label { display: block; text-align: center; cursor: pointer; }
.upload-label.disabled { opacity: .6; pointer-events: none; }

/* ---- Modal / önizleme ---- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(3,6,11,.74); backdrop-filter: blur(8px);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 0;
}
.modal {
    width: 100%; max-width: 560px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    max-height: 92dvh; overflow-y: auto;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { margin-left: auto; background: var(--card-2); border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.preview-media { width: 100%; max-height: 360px; object-fit: contain; border-radius: 12px; background: #000; margin-bottom: 12px; }
.kv { display: flex; gap: 8px; font-size: 13px; margin: 4px 0; }
.kv .k { color: var(--text-dim); min-width: 90px; }
.dup-warn { display: flex; align-items: flex-start; gap: 8px; background: rgba(247,119,55,.14); border: 1px solid rgba(247,119,55,.5); color: #ffc234; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.dup-warn .icon { width: 17px; height: 17px; margin-top: 1px; }

/* ---- Toast ---- */
#toast {
    position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
    background: var(--card-2); border: 1px solid var(--border); color: var(--text);
    padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 100;
    opacity: 0; transition: all .25s ease; pointer-events: none; max-width: 90vw; box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--red); }
#toast.ok { border-color: var(--green); }

/* ---- Yükleniyor ---- */
.loading { text-align: center; color: var(--text-dim); padding: 30px 0; font-size: 14px; }
.empty { text-align: center; color: var(--text-dim); padding: 40px 16px; }
.empty .ico { opacity: .5; }
.empty .ico .icon { width: 38px; height: 38px; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---- Dar mobil: iki alanlı satırları tek sütuna indir ---- */
@media (max-width: 520px) {
    .field-2 { grid-template-columns: 1fr; }
    .ai-provider-switch { grid-template-columns: 1fr; }
}

/* ---- Masaüstü ince ayar ---- */
@media (min-width: 760px) {
    .modal-overlay { align-items: center; }
    .modal { border-radius: 18px; }
    .gallery { grid-template-columns: repeat(4, 1fr); }
    .bottom-nav { left: 50%; right: auto; bottom: 18px; width: min(660px, calc(100% - 32px)); transform: translateX(-50%); border: 1px solid var(--border); border-radius: 18px; padding: 7px 9px; box-shadow: 0 18px 50px rgba(0,0,0,.36); }
    main.content { padding-bottom: 120px; }
}
