/* TPMedia Creative Manager — admin/client layout
 * Dark sidebar + light content, inspired by dash.lemontbyan (Metronic-ish)
 */

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--ff-body, "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-size: var(--font-base, 13px);
    color: var(--c-text-body, #1f2937);
    background: var(--c-bg-soft, #f0f3f9);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
*, *::before, *::after { box-sizing: border-box; }
a { color: var(--c-primary, #3b82f6); text-decoration: none; }

/* Grid shell */
.tpm-app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}
.tpm-app.is-collapsed { grid-template-columns: 72px 1fr; }
.tpm-app.is-impersonating {
    grid-template-rows: auto 60px 1fr;
    grid-template-areas:
        "banner  banner"
        "sidebar topbar"
        "sidebar main";
}
.tpm-app.is-impersonating .tpm-imp-banner { grid-area: banner; }

/* ═══ SIDEBAR (dark) ═══ */
.tpm-sidebar {
    grid-area: sidebar;
    background: #0f172a;          /* slate-900 dark */
    color: #cbd5e1;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e293b;
}
.tpm-sidebar__brand {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
    background: #0b1324;
    flex-shrink: 0;
}
.tpm-sidebar__brand img.brand-full  { height: 30px; display: block; }
.tpm-sidebar__brand img.brand-mini  { height: 28px; display: none; }
.is-collapsed .tpm-sidebar__brand   { padding: 0; justify-content: center; }
.is-collapsed .tpm-sidebar__brand img.brand-full { display: none; }
.is-collapsed .tpm-sidebar__brand img.brand-mini { display: block; }
.tpm-sidebar__toggler {
    background: transparent; border: 0; color: #94a3b8;
    cursor: pointer; padding: 6px; border-radius: 4px;
}
.tpm-sidebar__toggler:hover { background: rgba(255,255,255,.06); color: #fff; }

.tpm-sidebar__nav {
    list-style: none;
    margin: 0; padding: 12px 0;
    overflow-y: auto;
    flex: 1;
}
.tpm-sidebar__nav li { margin: 1px 0; }
.tpm-sidebar__nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #cbd5e1;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.tpm-sidebar__nav li a i,
.tpm-sidebar__nav li a .sb-icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
    color: #64748b;
    flex-shrink: 0;
}
.tpm-sidebar__nav li a:hover {
    background: rgba(255,255,255,.04);
    color: #fff;
}
.tpm-sidebar__nav li a:hover i { color: #93c5fd; }
.tpm-sidebar__nav li.is-active a {
    color: #fff;
    background: linear-gradient(90deg, rgba(59,130,246,.15), transparent);
    border-left-color: #3b82f6;
}
.tpm-sidebar__nav li.is-active a i { color: #3b82f6; }
.is-collapsed .tpm-sidebar__nav li a { justify-content: center; padding: 10px 0; }
.is-collapsed .tpm-sidebar__nav li a .sb-label { display: none; }
.tpm-sidebar__section {
    padding: 14px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
}
.is-collapsed .tpm-sidebar__section { display: none; }
.tpm-sidebar__phase-tag {
    margin-left: auto;
    background: #1e293b;
    color: #64748b;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.is-collapsed .tpm-sidebar__phase-tag { display: none; }

/* ═══ TOPBAR ═══ */
.tpm-topbar {
    grid-area: topbar;
    background: #fff;
    border-bottom: 1px solid #e5e9f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.tpm-topbar__title {
    font-weight: 600;
    font-size: 15px;
    color: #0f172a;
}
.tpm-topbar__user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: #5f6b7a;
}
.tpm-topbar__user .tpm-role-badge {
    background: #ecfdf5;
    color: #047857;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.tpm-topbar__user .tpm-role-badge.role-client {
    background: #fef3c7; color: #92400e;
}
.tpm-topbar__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.tpm-topbar__user a {
    color: #5f6b7a;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tpm-topbar__user a:hover { color: #3b82f6; }

/* ═══ Impersonation banner ═══ */
.tpm-imp-banner {
    grid-column: 1 / -1;
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #78350f;
    padding: 10px 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #f59e0b;
}
.tpm-imp-banner i { margin-right: 6px; }
.tpm-imp-banner form { margin: 0; }
.tpm-imp-banner button {
    background: #92400e;
    color: #fff;
    border: 0;
    padding: 6px 14px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.tpm-imp-banner button:hover { background: #78350f; }
body.is-impersonating .tpm-topbar__title::after {
    content: ' · Xem dưới vai client';
    color: #92400e;
    font-weight: 600;
}

/* ═══ MAIN ═══ */
.tpm-main {
    grid-area: main;
    padding: 24px;
}
.tpm-page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.tpm-page-title h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
    letter-spacing: -0.01em;
}
.tpm-footer {
    grid-column: 1 / -1;
    text-align: center;
    padding: 12px;
    font-size: 12px;
    color: #94a3b8;
}

/* ═══ Filter / table ═══ */
.tpm-filter {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #fff;
    border: 1px solid #e5e9f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
}
.tpm-filter input, .tpm-filter select {
    padding: 7px 10px;
    border: 1px solid #e5e9f0;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}
.tpm-filter input:focus, .tpm-filter select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.tpm-empty {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
}

/* Form grid */
.tpm-form-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 14px 16px;
    align-items: start;
    max-width: 720px;
}
.tpm-form-grid label {
    font-weight: 500;
    color: #334155;
    padding-top: 6px;
}
.tpm-form-grid input,
.tpm-form-grid textarea,
.tpm-form-grid select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e5e9f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.tpm-form-grid input:focus,
.tpm-form-grid select:focus,
.tpm-form-grid textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.08);
}
.tpm-form-grid textarea { min-height: 80px; resize: vertical; }
.tpm-form-actions { grid-column: 2; display: flex; gap: 8px; }
.tpm-form-help { font-size: 11px; color: #64748b; margin-top: 4px; }
.tpm-form-section-title {
    grid-column: 1 / -1;
    margin: 8px 0 -4px;
    padding-top: 12px;
    border-top: 1px solid #e5e9f0;
    font-weight: 600;
    color: #1e293b;
    font-size: 13px;
}
.tpm-form-grid > .tpm-form-help { grid-column: 1 / -1; margin-top: 0; }

/* Pill */
.tpm-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: capitalize;
}
.tpm-pill--draft     { background: #fff7e6; color: #b45309; }
.tpm-pill--active    { background: #dcfce7; color: #047857; }
.tpm-pill--archived  { background: #f1f5f9; color: #64748b; }
.tpm-pill--suspended { background: #fee2e2; color: #b91c1c; }
.tpm-pill--expired   { background: #fef3c7; color: #92400e; }

/* Toast */
.tpm-toast {
    position: fixed; top: 16px; right: 16px;
    padding: 10px 14px; border-radius: 6px;
    color: #fff; font-size: 13px; z-index: 1000;
    box-shadow: 0 6px 16px rgba(0,0,0,.12);
    opacity: 0; transition: opacity .2s;
}
.tpm-toast.is-show { opacity: 1; }
.tpm-toast--ok  { background: #047857; }
.tpm-toast--err { background: #b91c1c; }

.adm-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}
/* Inline-flex row cho nhiều button trong 1 cell — gap đều, không xuống dòng. */
.tpm-btn-row { display: inline-flex; gap: 6px; align-items: center; flex-wrap: nowrap; }

/* Mobile */
@media (max-width: 992px) {
    .tpm-app {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "main";
    }
    .tpm-sidebar {
        position: fixed;
        left: 0; top: 0;
        width: 240px;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .2s;
    }
    .tpm-app.is-mobile-open .tpm-sidebar { transform: translateX(0); }
    .tpm-sidebar__toggler--mobile { display: inline-flex; }
}

/* ══ Inline asset editor modal ════════════════════════════════════ */
.tpm-modal-asset {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}
.tpm-modal-asset__dialog {
    background: var(--c-white, #fff);
    border-radius: var(--r-md, 8px);
    box-shadow: var(--shadow-card, 0 10px 30px rgba(0,0,0,.2));
    width: min(1100px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.tpm-modal-asset__head,
.tpm-modal-asset__foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--c-border, #e5e9f0);
    background: var(--c-bg-soft, #f8fafc);
}
.tpm-modal-asset__head b { margin-right: 4px; }
.tpm-modal-asset__head .ae-close { margin-left: auto; }
.tpm-modal-asset__foot {
    border-bottom: 0;
    border-top: 1px solid var(--c-border, #e5e9f0);
    justify-content: flex-end;
}
.tpm-modal-asset__foot #ae-status { margin-right: auto; }
.tpm-modal-asset .tpm-warn { color: var(--c-danger, #b91c1c); font-weight: 600; }

.tpm-info-banner {
    background: var(--c-info-bg, #eff6ff);
    border-left: 4px solid var(--c-info, #2563eb);
    color: var(--c-text-body, #1e293b);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tpm-info-banner .la { color: var(--c-info, #2563eb); font-size: 18px; }

/* ══ Lazy edit state ════════════════════════════════════════════════ */
.tpm-hidden { display: none !important; }

.tpm-dirty-flag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--r-md, 6px);
    background: #fef3c7;
    color: #b45309;
    font-size: 12px;
    font-weight: 600;
    margin-left: 6px;
}

.tpm-asset-dirty {
    color: #b45309;
    font-weight: 700;
    margin-right: 4px;
}

.tpm-row-dirty {
    background: #fffbeb;
}
.tpm-row-dirty:hover {
    background: #fef3c7;
}
.tpm-modal-asset__area {
    flex: 1;
    min-height: 360px;
    border: 0;
    border-radius: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px 16px;
    resize: none;
    outline: none;
}
