/* =====================================================================
   TYZData - Design System
   Pembe/lila aksanlı, akademik ama modern
   ===================================================================== */

:root {
    /* Renk Paleti */
    --bg:           #fafaf7;
    --bg-soft:      #f3f0ec;
    --surface:      #ffffff;
    --ink:          #1a1822;
    --ink-soft:     #4a4858;
    --ink-mute:     #8a8898;
    --line:         #e8e4dd;
    --line-soft:    #f0ece6;

    --accent:       #c08aa8;     /* dusty rose */
    --accent-deep:  #8b5575;
    --accent-soft:  #f5e8ee;
    --accent-glow:  rgba(192, 138, 168, 0.15);

    --lilac:        #b8a5cf;
    --lilac-soft:   #ebe4f3;

    --success:      #6b9e7c;
    --warning:      #c9985a;
    --danger:       #b86468;

    --shadow-sm:    0 1px 2px rgba(26, 24, 34, 0.04);
    --shadow:       0 4px 16px rgba(26, 24, 34, 0.06), 0 1px 3px rgba(26, 24, 34, 0.04);
    --shadow-lg:    0 12px 40px rgba(26, 24, 34, 0.08), 0 4px 12px rgba(26, 24, 34, 0.04);

    --radius-sm:    6px;
    --radius:       10px;
    --radius-lg:    16px;

    --font-display: 'Fraunces', 'Source Serif Pro', Georgia, serif;
    --font-body:    'Inter Tight', 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'Menlo', monospace;
}

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

html, body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
}
h1 { font-size: 2.25rem; line-height: 1.15; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem;  line-height: 1.25; }
h3 { font-size: 1.15rem; line-height: 1.3; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ====== LAYOUT ====== */
.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.brand .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

/* ====== Renkli marka adı (StatWizai tarzı) ====== */
.brand-fancy {
    font-family: 'Sora', 'Inter Tight', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -0.025em;
    align-items: center;
    gap: 0;
}
.login-card .brand-fancy { font-size: 2.4rem; }
.brand-part-dark {
    color: var(--ink);
}
.brand-part-grad {
    background: linear-gradient(135deg,
        #c97aa3 0%,    /* pembe */
        #a366cc 33%,   /* mor */
        #6e8de8 66%,   /* lila-mavi */
        #4ab3b1 100%   /* turkuaz */
    );
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: brandGradientShift 8s ease-in-out infinite;
    padding: 0 1px;
}
.brand-fancy .dot {
    width: 10px; height: 10px;
    margin-left: 6px;
    background: linear-gradient(135deg, #c97aa3, #4ab3b1);
    box-shadow: 0 0 0 2px rgba(201, 122, 163, 0.15);
}
@keyframes brandGradientShift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}
/* Sidebar versiyonu daha küçük ve sade */
.sidebar .brand-fancy {
    font-size: 1.4rem;
}
.sidebar .brand-fancy .dot {
    width: 7px; height: 7px;
    margin-left: 4px;
}
/* Hareket azaltma tercihine saygı */
@media (prefers-reduced-motion: reduce) {
    .brand-part-grad { animation: none; }
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--ink-mute);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    margin-bottom: 32px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 450;
    transition: all 0.15s;
    cursor: pointer;
}
.nav-item:hover {
    background: var(--accent-soft);
    color: var(--accent-deep);
    text-decoration: none;
}
.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-weight: 500;
}
.nav-item .icon { width: 16px; height: 16px; opacity: 0.7; }
.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-mute);
    padding: 16px 12px 6px;
    font-weight: 600;
}

.main {
    padding: 36px 48px;
    max-width: 1400px;
    width: 100%;
}

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.8rem; }
.topbar .sub {
    font-size: 0.85rem;
    color: var(--ink-mute);
    margin-top: 4px;
}
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 100px;
    font-size: 0.85rem;
}
.user-chip .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--lilac));
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.78rem;
}

/* ====== CARD ====== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.card.hover:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
    transition: all 0.2s;
}

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ====== STATS ====== */
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--lilac));
}
.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-mute);
    font-weight: 500;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 500;
    margin-top: 8px;
    color: var(--ink);
}
.stat-meta { font-size: 0.78rem; color: var(--ink-mute); margin-top: 4px; }

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary {
    background: var(--ink);
    color: var(--bg);
}
.btn-primary:hover {
    background: var(--accent-deep);
    text-decoration: none;
    transform: translateY(-1px);
}
.btn-accent {
    background: var(--accent);
    color: white;
}
.btn-accent:hover { background: var(--accent-deep); text-decoration: none; }
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-ghost:hover {
    background: var(--bg-soft);
    color: var(--ink);
    text-decoration: none;
}
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--line);
}
.btn-danger:hover { background: rgba(184, 100, 104, 0.08); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ====== FORMS ====== */
.field {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 16px;
}
.field label {
    font-size: 0.85rem;
    color: var(--ink-soft);
    font-weight: 500;
}
.field label .req { color: var(--accent-deep); }
.field input, .field select, .field textarea {
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    background: var(--surface);
    color: var(--ink);
    transition: all 0.15s;
    width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.field .help { font-size: 0.78rem; color: var(--ink-mute); }

/* ====== TABLE ====== */
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    font-size: 0.9rem;
    overflow: visible;
}
/* Border-radius'u korumak için ilk/son hücrelere köşe ver */
table.data thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
table.data thead tr:first-child th:last-child  { border-top-right-radius: var(--radius); }
table.data tbody tr:last-child td:first-child  { border-bottom-left-radius: var(--radius); }
table.data tbody tr:last-child td:last-child   { border-bottom-right-radius: var(--radius); }
table.data th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-soft);
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--line);
}
table.data td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
}
table.data tbody tr:hover { background: var(--bg-soft); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ====== BADGES ====== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-design   { background: var(--lilac-soft); color: #6b5586; }
.badge-active   { background: #e3f0e6; color: var(--success); }
.badge-closed   { background: var(--bg-soft); color: var(--ink-mute); }
.badge-archived { background: var(--bg-soft); color: var(--ink-mute); }
.badge-admin       { background: var(--accent-soft); color: var(--accent-deep); }
.badge-coordinator { background: var(--lilac-soft); color: #6b5586; }
.badge-site_admin  { background: #fde8f0; color: #a04875; }
.badge-data_entry  { background: #e8eef5; color: #4a6a8c; }
.badge-monitor     { background: #fdf3e3; color: var(--warning); }
.badge-viewer      { background: var(--bg-soft); color: var(--ink-mute); }

/* ====== MODAL ====== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(26, 24, 34, 0.4);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    animation: fade 0.15s;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 560px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: pop 0.2s;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ====== EMPTY STATE ====== */
.empty {
    text-align: center;
    padding: 64px 32px;
    color: var(--ink-mute);
}
.empty .ico {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

/* ====== TOAST ====== */
.toast-host {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 200;
}
.toast {
    background: var(--ink);
    color: var(--bg);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } }

/* ====== FORM DESIGNER ====== */
.designer {
    display: grid;
    grid-template-columns: 240px 1fr 320px;
    gap: 20px;
    height: calc(100vh - 200px);
}
.designer-sidebar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
}
.designer-canvas {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    overflow-y: auto;
}
.designer-props {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
}
.field-template {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: grab;
    font-size: 0.86rem;
    transition: all 0.15s;
}
.field-template:hover { border-color: var(--accent); background: var(--accent-soft); }
.field-template:active { cursor: grabbing; }
.field-template .ico {
    width: 24px; height: 24px;
    background: var(--bg-soft);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    color: var(--accent-deep);
}

.canvas-field {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.canvas-field:hover { border-color: var(--accent); }
.canvas-field.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.canvas-field .label { font-weight: 500; font-size: 0.92rem; }
.canvas-field .meta {
    font-size: 0.76rem; color: var(--ink-mute); margin-top: 3px;
    font-family: var(--font-mono);
}
.canvas-field .actions {
    position: absolute; top: 10px; right: 10px;
    opacity: 0; transition: opacity 0.15s;
    display: flex; gap: 4px;
}
.canvas-field:hover .actions { opacity: 1; }

/* ====== LOGIN ====== */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
    top: -200px; right: -200px;
    pointer-events: none;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--lilac-soft) 0%, transparent 70%);
    bottom: -150px; left: -150px;
    pointer-events: none;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 48px;
    max-width: 420px;
    width: 90%;
    margin: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    position: relative;
    z-index: 1;
}
.login-card .brand { font-size: 2rem; }
.login-card h1 {
    font-size: 1.6rem;
    margin: 24px 0 6px;
}
.login-card .lead {
    color: var(--ink-mute);
    font-size: 0.92rem;
    margin-bottom: 32px;
}

/* ====== UTILITIES ====== */
.hstack { display: flex; align-items: center; gap: 12px; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.muted  { color: var(--ink-mute); }
.small  { font-size: 0.84rem; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-right { text-align: right; }

/* Mobile */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .main { padding: 24px; }
    .designer { grid-template-columns: 1fr; height: auto; }
}

/* ====== FLASH MESSAGES ====== */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid;
}
.flash-success { background: #f0f7f2; border-color: var(--success); color: #3d6049; }
.flash-error   { background: #fbf0f1; border-color: var(--danger);  color: #7d3a3d; }
.flash-info    { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }
.flash-warning { background: #fdf6e9; border-color: var(--warning); color: #785020; }

/* Form helpers */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* Export menu */
.export-opt {
    display: block; width: 100%; text-align: left;
    padding: 10px 14px; border-radius: var(--radius-sm);
    background: transparent; border: none; cursor: pointer;
    font-family: inherit; font-size: 0.88rem; color: var(--ink);
    transition: background 0.15s; text-decoration: none;
}
.export-opt:hover { background: var(--accent-soft); text-decoration: none; }
.export-opt + .export-opt { margin-top: 2px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab {
    padding: 10px 18px; font-size: 0.92rem; font-weight: 500;
    color: var(--ink-mute); cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -1px; transition: all 0.15s; text-decoration: none;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--accent-deep); border-bottom-color: var(--accent); }

/* Audit row */
.audit-row {
    display: grid; grid-template-columns: 160px 140px 100px 1fr;
    gap: 12px; padding: 8px 12px; font-size: 0.85rem;
    border-bottom: 1px solid var(--line-soft);
}
.audit-row:hover { background: var(--bg-soft); }
.audit-action { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-deep); }

/* ====== FILE UPLOAD ====== */
.file-upload-wrap { padding: 8px 0; }
.file-current {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; background: var(--accent-soft);
    border-radius: var(--radius-sm); border: 1px solid var(--accent);
}
.file-icon { font-size: 1.2rem; }
.file-link { color: var(--accent-deep); text-decoration: none; }
.file-link:hover { text-decoration: underline; }
.file-input { padding: 6px; font-family: inherit; font-size: 0.88rem; }

/* ====== CREDENTIALS CARD COMPONENTS ====== */
/* (already in users.php inline, here just placeholder) */

/* Marka logosu — background transparency koruması */
.sidebar img,
.login-card img {
    background: transparent;
    object-fit: contain;
}
