/* =========================
   Fonts & Root Variables
========================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #4f46e5, #06b6d4);
    --primary: #4f46e5;
    --accent: #06b6d4;
    --bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.82);
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --shadow-sm: 0 4px 12px rgba(0,0,0,.05);
    --shadow-md: 0 12px 30px rgba(0,0,0,.08);
    --shadow-lg: 0 20px 40px rgba(0,0,0,.12);
}

/* =========================
   Base Styles
========================= */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 60px;
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-image: linear-gradient(rgba(10, 22, 45, 0.52), rgba(10, 22, 45, 0.52)), url('/images/dashboard-bg.png') !important;
    background-size: cover !important;
    background-position: center !important;
    background-attachment: fixed !important;
    background-repeat: no-repeat !important;
    color: var(--text-dark);
}

.db-header-left h2, .mapping-header-left h2 {
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.db-header-left p, .mapping-header-left p {
    color: rgba(255, 255, 255, 0.85) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.container {
    max-width: 1100px;
}

/* =========================
   Typography
========================= */
h1, h2, h3, h4 {
    font-weight: 700;
    color: var(--text-dark);
}

    h4.mb-0 {
        font-weight: 600;
    }

/* =========================
   Navbar / Branding
========================= */
.navbar-brand {
    font-weight: 700;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
}

/* =========================
   Cards
========================= */
.card,
.glass-card,
.query-main-card,
.db-main-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

    .card .card-body {
        padding: 1.6rem;
    }

.glass-card {
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
}

/* =========================
   Gradient Info Panels
========================= */
.query-info-card,
.db-info-card,
.brand-panel {
    background: var(--primary-gradient);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

    .query-info-card h3,
    .db-info-card h3,
    .brand-panel h1 {
        font-weight: 700;
    }

    .query-info-card ul,
    .db-info-card ul {
        list-style: none;
        padding: 0;
        margin: 20px 0;
    }

/* =========================
   Buttons
========================= */
.btn-primary {
    background: var(--primary-gradient);
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(79,70,229,.25);
}

    .btn-primary:hover {
        opacity: 0.95;
    }

.btn-success {
    background: linear-gradient(90deg, #22c55e, #4ade80);
    border: none;
}

/* =========================
   Forms
========================= */

    .form-control:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 0.2rem rgba(6,182,212,.25);
        caret-color:violet;
    }

textarea.form-control {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.form-floating > .form-control::placeholder {
    color: var(--text-muted);
}

/* =========================
   Tables
========================= */
.table {
    background: transparent;
}

    .table thead th {
        font-weight: 600;
        color: var(--text-muted);
        border-bottom: 2px solid #e5e7eb;
    }

.table-hover tbody tr:hover {
    background: #f1f5f9;
}

/* =========================
   Pages Layouts
========================= */
.query-page,
.db-page,
.login-wrapper {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.query-container {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 40px;
    max-width: 1200px;
    width: 100%;
}

.db-container {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 40px;
    max-width: 1100px;
    width: 100%;
}

/* =========================
   Lists / Items
========================= */
.db-list {
    height: calc(100vh - 22rem);
    max-height:350px;
    overflow-y: auto;
    margin-bottom: 25px;
}

.db-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background .2s ease;
}

    .db-item:hover {
        background: #f1f5f9;
    }

.db-name {
    font-weight: 500;
}

/* =========================
   Responsive Tweaks
========================= */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .query-container,
    .db-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .card {
        margin: 0.5rem;
    }
}
thead {
    position: sticky;
    top: -1px;
}
.db-info-card h3, .brand-panel h1, .brand-logo {
    text-shadow: 0 0 5px black;
}
.query-header h4, .glass-card h3{
    text-shadow: 0 0 1px black;
}

/* ===================== TOAST ===================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    animation: toastSlideIn 0.25s ease-out;
    color: #fff;
}

    .toast.success {
        background: #22a55e;
    }

    .toast.error {
        background: #e0473e;
    }

    .toast.info {
        background: #3b6fd6;
    }

    .toast.warning {
        background: #e39b1f;
    }

    .toast .toast-close {
        margin-left: auto;
        cursor: pointer;
        opacity: 0.8;
        font-size: 16px;
        line-height: 1;
    }

        .toast .toast-close:hover {
            opacity: 1;
        }

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.toast-hide {
    animation: toastSlideOut 0.25s ease-in forwards;
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ===================== GLOBAL FULL-SCREEN LOADER ===================== */
.global-loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.global-loader-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #e0e0e0;
    border-top-color: #6a5cf5;
    border-radius: 50%;
    animation: ncmSpin 0.7s linear infinite;
}

/* ===================== BUTTON-LEVEL LOADER (reusable) ===================== */
.btn-loading {
    opacity: 0.7;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* ============================================================
   GLOBAL TOAST NOTIFICATIONS
   ============================================================ */

#globalToastContainer, .app-toast-container {
    position: fixed;
    top: 75px;
    right: 25px;
    width: auto;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999999;
    pointer-events: none;
}


/* ============================================================
   TOAST
   ============================================================ */

.app-toast {
    min-width: 320px;
    max-width: 420px;
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 10px;
    color: #ffffff;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.20);
    pointer-events: auto;
    animation: appToastSlideIn 0.25s ease-out;
}


/* ============================================================
   TOAST CONTENT
   ============================================================ */

.app-toast-content {
    flex: 1;
}

.app-toast-message {
    line-height: 1.4;
}


/* ============================================================
   CLOSE BUTTON
   ============================================================ */

.app-toast-close {
    margin-left: 15px;
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    opacity: 0.8;
}

    .app-toast-close:hover {
        opacity: 1;
    }


/* ============================================================
   SUCCESS
   ============================================================ */

.app-toast-success {
    background: #22a55e;
}


/* ============================================================
   ERROR
   ============================================================ */

.app-toast-error {
    background: #e0473e;
}


/* ============================================================
   INFO
   ============================================================ */

.app-toast-info {
    background: #3b6fd6;
}


/* ============================================================
   WARNING
   ============================================================ */

.app-toast-warning {
    background: #e39b1f;
}


/* ============================================================
   TOAST ANIMATION
   ============================================================ */

@keyframes appToastSlideIn {

    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


@keyframes appToastSlideOut {

    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}


.app-toast-hide {
    animation: appToastSlideOut 0.25s ease-in forwards;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 600px) {

    #globalToastContainer,
    .app-toast-container {
        left: 15px;
        right: 15px;
        top: 70px;
        max-width: none;
    }

    .app-toast {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: ncmSpin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes ncmSpin {
    to {
        transform: rotate(360deg);
    }
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    position: relative;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left h1 {
    font-size: 19px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
    color: #1c2430;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
}

.nav-item-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #1c2430;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item-link:hover {
    background: rgba(106, 92, 245, 0.08);
    color: #6a5cf5;
    text-decoration: none;
}

.admin {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6a5cf5, #8f7dfb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.admin .name {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    color: #1c2430;
}

.admin .role {
    font-size: 11.5px;
    color: #4e5d78;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #ef4b5f;
    background: rgba(239, 75, 95, 0.08);
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease;
    margin-left: 8px;
}

.logout-btn:hover {
    background: rgba(239, 75, 95, 0.15);
    transform: translateY(-1px);
    color: #ef4b5f;
}

@media (max-width: 720px) {
    .nav-links {
        gap: 4px;
        margin-right: 0;
    }
    .nav-item-link {
        padding: 6px 8px;
        font-size: 12px;
    }
}

footer.footer {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
}

