/* ============================================
   LTAT Chatbot Admin Panel — Royal Blue & Gold Theme
   Brand colors from the official LTAT logo:
   Royal Blue (ribbon), Gold (ornaments), Red (crown)
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 68px;
    --topbar-height: 60px;
    --primary: #1E3A6E;
    --primary-dark: #152C54;
    --primary-light: #D4DFF0;
    --accent-gold: #C49A2A;
    --accent-red: #C41E2A;
    --sidebar-bg: #0F1E3D;
    --sidebar-hover: #1A2E55;
    --sidebar-active: #1E3A6E;
    --topbar-bg: #1E3A6E;
    --content-bg: #f4f6f9;
}

/* ── Layout ── */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--content-bg);
    overflow-x: hidden;
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.admin-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.sidebar-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand i {
    color: var(--accent-gold);
    font-size: 1.4rem;
}

.sidebar-nav {
    height: calc(100vh - 6.5rem);
    padding: 15px 0;
    overflow: auto;
}

.sidebar-nav .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: var(--accent-gold);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    border-left-color: var(--accent-gold);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.nav-section {
    color: rgba(255,255,255,0.4);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 18px 20px 8px;
    font-weight: 600;
}

/* ── Main Content ── */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-collapsed-width);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* ── Top Bar ── */
.admin-topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.topbar-breadcrumb h5 {
    font-weight: 600;
    font-size: 1.05rem;
}

/* ── Topbar Right Section ── */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    white-space: nowrap;
}

/* ── Topbar Notification Bell ── */
.topbar-bell {
    position: relative;
    color: rgba(255,255,255,0.7);
    font-size: 1.15rem;
    text-decoration: none;
    transition: color 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-bell:hover { color: #fff; }

.topbar-bell-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background: #C49A2A;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    padding: 0 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.topbar-bell.has-notifications { color: #fff; }
.topbar-bell.has-notifications .topbar-bell-badge { display: inline-block !important; }

@keyframes bellShake {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(12deg); }
    30% { transform: rotate(-10deg); }
    45% { transform: rotate(8deg); }
    60% { transform: rotate(-6deg); }
    75% { transform: rotate(3deg); }
}

.topbar-bell.bell-ring i {
    animation: bellShake 0.6s ease-in-out;
}

.admin-info {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

/* ── Content Area ── */
.admin-content {
    padding: 25px;
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 15px 20px;
    font-weight: 600;
    border-radius: 10px 10px 0 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

/* ── Buttons ── */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ── DataTable Overrides ── */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ── Status Badges ── */
.badge-active {
    background: #1E6E3A;
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
}

.badge-inactive {
    background: #dc3545;
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
}

.badge-popular {
    background: var(--accent-gold);
    color: #fff;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 0.75rem;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.2;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ── Category Icon Preview ── */
.icon-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
}

/* ── Sortable ── */
.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-light) !important;
}

.sortable-handle {
    cursor: grab;
    color: #aaa;
}

.sortable-handle:active {
    cursor: grabbing;
}

/* ── Action Buttons in Tables ── */
.btn-action {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 5px;
}

/* ── Login Page ── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #0A1628 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    padding: 30px 20px 20px;
}

.login-header img {
    max-height: 80px;
    object-fit: contain;
}

.login-header i {
    font-size: 3rem;
    color: var(--primary);
}

.login-header h4 {
    margin-top: 10px;
    font-weight: 700;
    color: #333;
}

/* ── Form Enhancements ── */
.form-label-required::after {
    content: ' *';
    color: #dc3545;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: var(--sidebar-bg);
}

.sidebar-persist-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
    cursor: pointer;
    margin: 0;
    white-space: nowrap;
}

.sidebar-persist-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-persist-label:hover {
    color: rgba(255,255,255,0.8);
}

/* ── Sidebar: Always collapsed, expand on hover as overlay ── */
.admin-sidebar {
    width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
    overflow: hidden;
    transition: width 0.25s ease, max-width 0.25s ease, box-shadow 0.25s ease;
}

.admin-sidebar .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    display: inline-block;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.admin-sidebar .sidebar-brand {
    justify-content: center;
}

.admin-sidebar .sidebar-brand i {
    margin-right: 0 !important;
}

.admin-sidebar .sidebar-header {
    padding: 20px 10px;
}

.admin-sidebar .sidebar-nav .nav-link {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
    border-left-width: 2px;
}

.admin-sidebar .sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: auto;
}

.admin-sidebar .nav-section {
    padding: 12px 0 4px;
    text-align: center;
    font-size: 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    min-height: 8px;
}

.admin-sidebar .sidebar-footer {
    padding: 10px 8px;
}

.admin-sidebar .sidebar-persist-label .sidebar-text {
    display: none;
}

.admin-sidebar .sidebar-persist-label {
    justify-content: center;
}

/* ── Hover expand: overlay on top of content ── */
.admin-sidebar:hover {
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

.admin-sidebar:hover .sidebar-text {
    opacity: 1;
    width: auto;
}

.admin-sidebar:hover .sidebar-brand {
    justify-content: flex-start;
}

.admin-sidebar:hover .sidebar-brand i {
    margin-right: 0.5rem !important;
}

.admin-sidebar:hover .sidebar-header {
    padding: 20px;
}

.admin-sidebar:hover .sidebar-nav .nav-link {
    justify-content: flex-start;
    padding: 12px 20px;
    gap: 12px;
    border-left-width: 3px;
}

.admin-sidebar:hover .sidebar-nav .nav-link i {
    font-size: 0.95rem;
    width: 20px;
}

.admin-sidebar:hover .nav-section {
    padding: 18px 20px 8px;
    text-align: left;
    font-size: 0.72rem;
    border-bottom: none;
}

.admin-sidebar:hover .sidebar-footer {
    padding: 12px 20px;
}

.admin-sidebar:hover .sidebar-persist-label .sidebar-text {
    display: inline;
}

.admin-sidebar:hover .sidebar-persist-label {
    justify-content: flex-start;
}

/* ── Admin Tooltips (black background, full text on hover) ──
   Structure: <span class="admin-tooltip-wrap"><span class="admin-tooltip" data-tooltip="...">text</span></span>
   The wrapper has overflow:visible so the tooltip pseudo-element isn't clipped.
   The inner .admin-tooltip handles text truncation.
*/
.admin-tooltip-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: middle;
}

.admin-tooltip-wrap .admin-tooltip {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

.admin-tooltip-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #1a1a1a;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    max-width: 400px;
    min-width: 180px;
    width: max-content;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.admin-tooltip-wrap::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 16px;
    border: 5px solid transparent;
    border-top-color: #1a1a1a;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.admin-tooltip-wrap:hover::after,
.admin-tooltip-wrap:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        max-width: var(--sidebar-width);
    }

    .admin-sidebar .sidebar-text {
        opacity: 1;
        width: auto;
    }

    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .admin-main {
        margin-left: 0;
        width: 100%;
    }

    .admin-content {
        padding: 15px;
    }

    /* Topbar: tighter spacing on mobile */
    .admin-topbar { padding: 8px 12px; }
    .admin-topbar h5 { font-size: 1rem; }
}

/* ── PWA: Standalone display adjustments ── */
@media (display-mode: standalone) {
    /* Tighter top spacing when running as installed PWA (no browser chrome) */
    .admin-topbar {
        padding-top: env(safe-area-inset-top, 8px);
    }

    .admin-content {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* ── Small mobile: tighter still ── */
@media (max-width: 480px) {
    .admin-content { padding: 10px; }
    .admin-topbar h5 { font-size: 0.92rem; }

    /* Hide admin name text on very small screens — bell + icon sufficient */
    .admin-info span { display: none; }
    .admin-info { font-size: 0.85rem; }

    /* Full-width cards and tables */
    .card { border-radius: 0; margin-left: -10px; margin-right: -10px; }
    .table { font-size: 0.82rem; }
}
