/* ==========================================================================
   MigraPath — Premium Ana Stil Dosyası
   Layout, Navigasyon, Sidebar, Responsive, Animasyonlar
   ========================================================================== */

/* ---------- Reset & Genel ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    background: var(--gradient-body);
    overflow-x: hidden;
}

/* Grid arka plan deseni */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 88%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 88%);
}

/* Radial glow efektleri */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(920px 460px at 8% -2%, var(--gradient-radial-blue), transparent 58%),
        radial-gradient(720px 360px at 92% 0%, var(--gradient-radial-gold), transparent 54%);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* ---------- Auth Layout ---------- */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem 0.75rem;
    position: relative;
}

.auth-container {
    width: 100%;
    max-width: 540px;
    animation: fadeSlideUp 0.6s ease both;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.25rem;
}

.auth-brand-logo {
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 0 14px rgba(255,255,255,0.3)) drop-shadow(0 12px 28px rgba(0,0,0,0.4));
    animation: logoFloat 5s ease-in-out infinite;
}

/* Tema / Dil toggle — auth sayfası */
.auth-toggles {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

/* ---------- Dashboard Layout ---------- */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 270px;
    background:
        linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.sidebar-brand {
    padding: 0.4rem 3rem 0.2rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    max-width: 150px;
    height: auto;
    display: block;
    padding: 0.25rem 0;
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.2)) drop-shadow(0 6px 16px rgba(0,0,0,0.3));
}

.sidebar-nav {
    flex: 1;
    padding: 0.6rem 0;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu-item {
    margin: 0.1rem 0.6rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.22s ease;
}

.sidebar-menu-link:hover {
    color: var(--text-primary);
    background: var(--gradient-card);
    border-color: var(--border);
    box-shadow: var(--shadow-soft);
    transform: translateX(2px);
}

.sidebar-menu-item.active .sidebar-menu-link {
    color: var(--accent-light);
    background: linear-gradient(135deg, rgba(191, 147, 65, 0.14), rgba(143, 174, 226, 0.08));
    border-color: var(--border-accent);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--border-accent);
}

.sidebar-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}

/* ---------- Üst Navigasyon Çubuğu ---------- */
.main-content {
    flex: 1;
    margin-left: 270px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: calc(100vw - 270px);
    overflow-x: hidden;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(1, 5, 16, 0.12);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-user {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Toggle butonları (tema / dil) */
.toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0.35rem 0.6rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.22s ease;
}

.toggle-btn:hover {
    border-color: var(--border-accent);
    color: var(--accent);
    background: var(--glass-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

/* Logout butonu */
.btn-logout {
    padding: 0.35rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.22s ease;
}

.btn-logout:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-bg);
}

.navbar-logout-form {
    display: inline;
}

/* Mobil menü butonu */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* ---------- İçerik Alanı ---------- */
.content {
    flex: 1;
    padding: 1.25rem;
}

.page-header {
    margin-bottom: 1rem;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

/* ---------- Dashboard İçerik ---------- */
.dashboard-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin-bottom: 0.35rem;
}

/* ---------- Sidebar overlay (mobil) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 45;
    transition: opacity 0.28s ease;
}

.sidebar-overlay.active {
    display: block;
}

/* ---------- Global loading overlay ---------- */
.global-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--overlay);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.global-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.global-loading-card {
    width: min(92vw, 320px);
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--gradient-card);
    box-shadow: var(--shadow-soft);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.global-loading-spinner {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    animation: globalSpin 0.9s linear infinite;
    flex: 0 0 auto;
}

.global-loading-text {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

body.global-loading-active {
    overflow: hidden;
    touch-action: none;
}

/* ---------- Footer ---------- */
.app-footer {
    text-align: center;
    padding: 0.85rem 1.25rem;
    font-size: 0.75rem;
    color: var(--text-soft);
    border-top: 1px solid var(--border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 100%;
    box-sizing: border-box;
}

.footer-separator {
    margin: 0 0.4rem;
    opacity: 0.4;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ==========================================================================
   Animasyonlar
   ========================================================================== */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes errorSweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes errorPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes errorFloatA {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(10px, -10px, 0); }
}

@keyframes errorFloatB {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(-12px, 9px, 0); }
}

@keyframes errorFloatC {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, -11px, 0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes globalSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Error Sayfaları (403, 404) — Premium Animasyonlu
   ========================================================================== */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    position: relative;
}

.error-wrapper {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: center;
    animation: fadeSlideUp 0.6s ease both;
}

.error-copy {
    max-width: 28rem;
}

.error-brand {
    margin-bottom: 2rem;
}

.error-brand-logo {
    max-width: 160px;
    height: auto;
    filter: drop-shadow(0 0 11px rgba(255,255,255,0.3)) drop-shadow(0 10px 24px rgba(0,0,0,0.4));
}

.error-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.48rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-accent);
    background: var(--card-bg);
    color: var(--accent-light);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.error-title {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.08;
    letter-spacing: -0.04em;
    margin-bottom: 1rem;
}

.error-description {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.72;
    margin-bottom: 1.5rem;
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Animasyonlu görsel panel */
.error-visual {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    border: 1px solid var(--border);
    background:
        radial-gradient(300px 220px at 80% 12%, var(--gradient-radial-gold), transparent 72%),
        radial-gradient(320px 200px at 16% 84%, var(--gradient-radial-blue), transparent 72%),
        var(--gradient-card);
    min-height: clamp(280px, 34vw, 400px);
    box-shadow: var(--shadow-deep);
    isolation: isolate;
}

.error-visual::before {
    content: "";
    position: absolute;
    inset: -24%;
    background: conic-gradient(from 0deg, transparent 0deg, var(--gradient-radial-blue) 120deg, transparent 220deg);
    animation: errorSweep 8s linear infinite;
    opacity: 0.5;
    pointer-events: none;
}

.error-code-shell {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-content: center;
    gap: 0.5rem;
    text-align: center;
}

.error-code-big {
    color: var(--text-primary);
    font-size: clamp(4rem, 10vw, 7.5rem);
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -0.05em;
    text-shadow: 0 16px 36px rgba(1, 5, 16, 0.5);
    animation: errorPulse 3.8s ease-in-out infinite;
}

.error-code-label {
    color: var(--accent-light);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.82rem;
}

/* Floating orbs */
.error-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(2px);
    pointer-events: none;
}

.error-orb-a {
    width: 150px;
    height: 150px;
    top: 12%;
    left: 8%;
    background: radial-gradient(circle, rgba(214, 176, 102, 0.48), rgba(214, 176, 102, 0.08) 66%, transparent 74%);
    animation: errorFloatA 6.8s ease-in-out infinite;
}

.error-orb-b {
    width: 188px;
    height: 188px;
    right: 8%;
    bottom: 10%;
    background: radial-gradient(circle, rgba(143, 174, 226, 0.5), rgba(143, 174, 226, 0.08) 68%, transparent 76%);
    animation: errorFloatB 7.2s ease-in-out infinite;
}

.error-orb-c {
    width: 108px;
    height: 108px;
    left: 46%;
    bottom: 18%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05) 70%, transparent 82%);
    animation: errorFloatC 5.8s ease-in-out infinite;
}

/* ==========================================================================
   Responsive Tasarım
   ========================================================================== */

/* ---------- Tablet (max-width: 1024px) ---------- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }

    .sidebar-toggle {
        display: block;
    }

    .content {
        padding: 1rem;
    }

    .error-wrapper {
        grid-template-columns: 1fr;
    }

    .error-visual {
        min-height: clamp(240px, 50vw, 320px);
    }
}

/* ---------- Mobil (max-width: 640px) ---------- */
@media (max-width: 640px) {
    .auth-layout {
        padding: 0.75rem 0.5rem;
    }

    .auth-brand {
        margin-bottom: 0.75rem;
    }

    .auth-brand-logo {
        max-width: 140px;
    }

    .card {
        padding: 1.15rem 1rem;
        border-radius: 16px;
    }

    .navbar {
        padding: 0.4rem 0.75rem;
    }

    .navbar-title {
        display: none;
    }

    .content {
        padding: 0.75rem;
    }

    .navbar-user,
    .navbar-username-text {
        display: none;
    }

    .navbar-role-pill {
        display: none;
    }

    /* Mobilde logout sadece ikon */
    .logout-text {
        display: none;
    }

    .app-footer {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.6rem 0.75rem;
        font-size: 0.7rem;
    }

    .footer-separator {
        display: none;
    }

    .logout-icon {
        margin-right: 0 !important;
    }

    .btn {
        padding: 0.55rem 0.85rem;
        font-size: 0.8125rem;
    }

    .notification-dropdown {
        width: min(300px, calc(100vw - 2rem));
        right: -60px;
    }

    .error-wrapper {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .error-title {
        font-size: clamp(1.6rem, 8vw, 2.4rem);
    }

    .error-actions {
        flex-direction: column;
    }

    .error-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .error-code-big {
        font-size: clamp(3rem, 18vw, 5rem);
    }

    .page-header {
        margin-bottom: 0.75rem;
    }

    .page-header h1,
    .page-title {
        font-size: 1.15rem;
    }

    .page-subtitle {
        font-size: 0.8125rem;
    }

    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .toggle-btn {
        min-width: 32px;
        min-height: 32px;
        padding: 0.25rem 0.45rem;
        font-size: 0.75rem;
    }

    .sidebar-brand {
        padding: 0.35rem 2.5rem 0.2rem;
    }

    .sidebar-logo {
        max-width: 120px;
    }
}

/* ---------- Küçük Mobil (max-width: 400px) ---------- */
@media (max-width: 400px) {
    .auth-layout {
        padding: 0.5rem 0.35rem;
    }

    .card {
        padding: 1rem 0.75rem;
        border-radius: 14px;
    }

    .content {
        padding: 0.5rem;
    }

    .navbar {
        padding: 0.35rem 0.5rem;
    }

    .navbar-right {
        gap: 0.35rem;
    }

    .notification-dropdown {
        width: calc(100vw - 1.5rem);
        right: -80px;
    }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------- Turnstile Ayarlar ---------- */
.cf-turnstile {
    width: 100%;
    display: flex;
    justify-content: center;
}

.cf-turnstile iframe {
    max-width: 100%;
}
