/* ============================================================
   Melon Mobile Pipeline Portal — Global Styles
   Tailwind handles most utility work; this file covers
   custom components and anything Tailwind can't do inline.

   Environment-aware accent: green (prod) / orange (DEV).
   Set via data-env="prod|uat" on <body>.
   ============================================================ */

/* -- Environment Palette ---------------------------------------- */
body[data-env="prod"] {
    --accent:             #16a34a;
    --accent-dark:        #14532d;
    --accent-light:       #86efac;
    --accent-bg:          #dcfce7;
    --accent-bg-subtle:   #f0fdf4;
    --accent-hover-shadow: rgba(22,163,74,.15);
    --accent-focus-ring:  rgba(22,163,74,.12);
}

body[data-env="uat"] {
    --accent:             #FF6B35;
    --accent-dark:        #c2410c;
    --accent-light:       #fdba74;
    --accent-bg:          #ffedd5;
    --accent-bg-subtle:   #fff7ed;
    --accent-hover-shadow: rgba(255,107,53,.15);
    --accent-focus-ring:  rgba(255,107,53,.12);
}

/* Fallback if data-env is missing */
body:not([data-env]) {
    --accent:             #16a34a;
    --accent-dark:        #14532d;
    --accent-light:       #86efac;
    --accent-bg:          #dcfce7;
    --accent-bg-subtle:   #f0fdf4;
    --accent-hover-shadow: rgba(22,163,74,.15);
    --accent-focus-ring:  rgba(22,163,74,.12);
}

/* -- Base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--accent-bg-subtle);
    margin: 0;
    padding: 0;
}

/* -- Header ----------------------------------------------------- */
.tb-header {
    background: #ffffff;
    border-top: 4px solid var(--accent);
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    position: sticky;
    top: 0;
    z-index: 50;
}

.tb-header-inner {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.tb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.tb-logo {
    height: 32px;
    width: auto;
}

.tb-wordmark {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.3px;
}

/* Environment badge */
.tb-env-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
    background: var(--accent);
    margin-left: 4px;
    vertical-align: middle;
}

.tb-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tb-agent {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tb-role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.tb-role-badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.tb-role-badge-agent {
    background: #dbeafe;
    color: #1e40af;
}

.tb-agent-name {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.tb-agent-email {
    font-size: 13px;
    color: #6b7280;
}

.tb-header-btn {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-decoration: none;
    padding: 5px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background .15s, color .15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tb-header-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.tb-logout {
    font-size: 13px;
    font-weight: 600;
    color: #dc2626;
    text-decoration: none;
    padding: 5px 12px;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.tb-logout:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* -- Layout: Sidebar + Main ------------------------------------- */
.tb-layout {
    display: flex;
    min-height: calc(100vh - 52px - 42px); /* header + footer */
}

.tb-sidebar {
    width: 220px;
    min-width: 220px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    padding: 16px 0;
    overflow-y: auto;
}

.tb-sidebar-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9ca3af;
    padding: 12px 20px 6px;
}

.tb-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    margin: 2px 10px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
}

.tb-sidebar-link:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #111827;
}

.tb-sidebar-link.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    font-weight: 600;
}

.tb-sidebar-link.active i {
    color: #ffffff;
}

.tb-sidebar-link i {
    width: 18px;
    text-align: center;
    font-size: 15px;
    color: #6b7280;
}

.tb-sidebar-link:hover i {
    color: #374151;
}

/* Denied queue icon — red normally, white when active */
.tb-sidebar-link .denied-icon { color: #dc3545; }
.tb-sidebar-link.active .denied-icon { color: #ffffff; }

.tb-main {
    flex: 1;
    padding: 24px 28px;
    min-width: 0;
    padding-bottom: 70px; /* space above fixed footer */
}

/* -- Footer ----------------------------------------------------- */
.tb-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 10px 24px;
    z-index: 40;
}

.tb-footer-inner {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #9ca3af;
}

.tb-footer-link { color: var(--accent); text-decoration: none; }
.tb-footer-link:hover { text-decoration: underline; }
.tb-footer-sep { color: #d1d5db; }
.tb-footer-version { font-weight: 600; color: #d1d5db; }

/* -- Page header ------------------------------------------------ */
.page-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

/* -- Cards ------------------------------------------------------ */
.tb-card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.card {
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border-radius: 10px;
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
}

/* -- Stat cards ------------------------------------------------- */
.stat-card {
    border-radius: 10px;
    padding: 1.25rem;
    color: #fff;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; margin-top: 4px; }

/* -- Tables ----------------------------------------------------- */
.table th {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6c757d;
    background: #f8f9fa;
}

/* -- Badges & tags ---------------------------------------------- */
.badge { font-size: .72rem; }
.btn-action { padding: 3px 10px; font-size: .78rem; }

.tag-badge {
    font-size: .68rem;
    padding: 2px 8px;
    border-radius: 12px;
    color: #fff;
    display: inline-block;
    margin: 1px 2px;
}
.tag-badge .bi-x { cursor: pointer; margin-left: 3px; }

/* -- Mentions --------------------------------------------------- */
.mention-highlight {
    background: #e3f2fd;
    color: #1565c0;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 500;
}

/* -- Follow-up due row ------------------------------------------ */
.follow-up-due { background: #fff3cd; }

/* -- Alerts (toolbox style) ------------------------------------- */
.alert-pipeline-error {
    background: #dc2626;
    color: #ffffff;
    border-left: 5px solid #991b1b;
    padding: 14px 18px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-pipeline-success {
    background: #16a34a;
    color: #ffffff;
    border-left: 5px solid #14532d;
    padding: 14px 18px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 20px;
}

/* -- Login card ------------------------------------------------- */
.login-card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    border-top: 4px solid var(--accent);
    width: 100%;
    max-width: 420px;
}

.login-logo {
    display: block;
    max-width: 180px;
    margin: 0 auto 20px;
}

.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 24px;
}

/* -- Accent utility classes ------------------------------------- */
.text-accent     { color: var(--accent) !important; }
.text-accent-dark { color: var(--accent-dark) !important; }
.bg-accent       { background: var(--accent) !important; }
.bg-accent-bg    { background: var(--accent-bg) !important; }
.border-accent   { border-color: var(--accent) !important; }
.accent-radio    { accent-color: var(--accent); }
.shadow-accent   { box-shadow: 0 0 0 2px var(--accent); }

/* -- Form focus ring -------------------------------------------- */
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-focus-ring);
}

/* -- Buttons: accent primary ------------------------------------ */
.btn-accent {
    background: var(--accent);
    color: #ffffff;
    border: none;
    font-weight: 600;
}
.btn-accent:hover {
    opacity: .9;
    color: #ffffff;
}

/* -- Responsive ------------------------------------------------- */
@media (max-width: 768px) {
    .tb-sidebar {
        display: none; /* collapse sidebar on mobile */
    }
    .tb-main {
        padding: 16px;
    }
    .tb-wordmark { display: none; }
    .tb-env-badge { display: none; }
    .tb-agent-name { display: none; }
}

/* -- Scrollbar -------------------------------------------------- */
::-webkit-scrollbar        { width: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
