/* ==========================================================================
   AutoPost Hub - Main CSS Stylesheet (All-in-One Premium Light Mode)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Primary Colors */
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-solid: #ffffff;
    --bg-input: #f1f5f9;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(99, 102, 241, 0.5);

    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-glow: rgba(15, 23, 42, 0.05);

    /* Accents & States */
    --primary: #4338ca;
    /* Indigo */
    --primary-hover: #4338ca;
    --primary-glow: rgba(79, 70, 229, 0.15);

    --success: #10b981;
    /* Emerald */
    --success-glow: rgba(16, 185, 129, 0.15);

    --warning: #f59e0b;
    /* Amber */
    --warning-glow: rgba(245, 158, 11, 0.15);

    --danger: #e11d48;
    /* Rose */
    --danger-glow: rgba(225, 29, 72, 0.15);

    --info: #0284c7;
    /* Sky Blue */
    --info-glow: rgba(2, 132, 199, 0.15);

    /* Excel / Spreadsheet Specific */
    --excel-header-bg: #f1f5f9;
    --excel-row-hover: rgba(241, 245, 249, 0.6);
    --excel-selected: rgba(79, 70, 229, 0.06);
    --excel-grid: rgba(0, 0, 0, 0.05);

    /* Mechanics */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition-speed: 0.2s;
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Typography */
    --font-main: 'Roboto', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--primary-hover);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   AutoPost Hub - Header (Glassmorphic Top Navigation)
   ========================================================================== */

header {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.header-logo i {
    font-size: 1.85rem;
    color: var(--primary);
    filter: drop-shadow(0 0 10px var(--primary-glow));
    transition: transform 0.3s var(--transition-bounce);
}


.header-logo h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #0f172a 30%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-indicator.online::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--success);
    animation: pulse 2s infinite;
}

.status-indicator.running {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-indicator.running::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* ==========================================================================
   AutoPost Hub - Stats Bar (Dashboard KPI Cards)
   ========================================================================== */

.stats-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    padding: 1.5rem 2rem 0.5rem 2rem;
    flex-shrink: 0;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    transition: all 0.3s var(--transition-bounce);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.01) 0%, transparent 70%);
    pointer-events: none;
    transition: transform 0.5s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.1);
}

.stat-card:hover::before {
    transform: translate(5%, 5%);
}

.stat-info {
    z-index: 1;
}

.stat-info h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

.stat-info p {
    font-size: 1.85rem;
    font-weight: 700;
    margin-top: 0.25rem;
    font-family: var(--font-mono);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    z-index: 1;
    transition: transform 0.3s var(--transition-bounce);
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(-5deg);
}

.stat-card.total-card {
    border-left: 4px solid var(--primary);
}

.stat-card.total-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.08);
}

.stat-card.pending-card {
    border-left: 4px solid var(--warning);
}

.stat-card.pending-card:hover {
    border-color: var(--warning);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.08);
}

.stat-card.success-card {
    border-left: 4px solid var(--success);
}

.stat-card.success-card:hover {
    border-color: var(--success);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.08);
}

.stat-card.failed-card {
    border-left: 4px solid var(--danger);
}

.stat-card.failed-card:hover {
    border-color: var(--danger);
    box-shadow: 0 8px 30px rgba(244, 63, 94, 0.08);
}

/* Completed (Hoàn thành) - teal/cyan xanh lá đậm */
.stat-card.completed-card {
    border-left: 4px solid #0d9488;
}

.stat-card.completed-card:hover {
    border-color: #0d9488;
    box-shadow: 0 8px 30px rgba(13, 148, 136, 0.08);
}

.stat-icon.total {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
}

.stat-icon.pending {
    background: rgba(245, 158, 11, 0.08);
    color: var(--warning);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.08);
    color: var(--success);
}

.stat-icon.failed {
    background: rgba(244, 63, 94, 0.08);
    color: var(--danger);
}

.stat-icon.completed {
    background: rgba(13, 148, 136, 0.08);
    color: #0d9488;
}

/* ==========================================================================
   AutoPost Hub - Toolbar Controls (Search & Action Buttons)
   ========================================================================== */

.toolbar {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    flex-shrink: 0;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 420px;
}

.search-box input {
    width: 100%;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    padding: 0.7rem 1.2rem 0.7rem 2.8rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: all var(--transition-speed);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: color var(--transition-speed);
}

.search-box input:focus+i {
    color: var(--primary);
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-bounce);
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn:hover {
    background: #f1f5f9;
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border-color: var(--success);
    color: white;
    box-shadow: 0 4px 12px var(--success-glow);
    position: relative;
}

.btn-success:hover {
    background: linear-gradient(135deg, #34d399 0%, var(--success) 100%);
    border-color: #34d399;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: rgba(225, 29, 72, 0.05);
    border-color: rgba(225, 29, 72, 0.15);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 4px 12px var(--danger-glow);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   AutoPost Hub - Table Spreadsheet Grid (Excel Sheet UI)
   ========================================================================== */

.table-wrapper {
    flex: 1;
    margin: 0 2rem 2rem 2rem;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    position: relative;
    min-height: 0;
    height: 100%;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.825rem;
    color: var(--text-main);
}

th {
    background: var(--excel-header-bg);
    color: var(--text-main);
    font-weight: 600;
    text-align: left;
    padding: 0.8rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    user-select: none;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

th:last-child {
    border-right: none;
}

td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--excel-grid);
    border-right: 1px solid var(--excel-grid);
    color: var(--text-main);
    vertical-align: middle;
    position: relative;
    max-width: 280px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--transition-speed);
}

td:last-child {
    border-right: none;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--excel-row-hover);
}

tr.selected td {
    background: var(--excel-selected);
}

.col-select {
    width: 45px;
    text-align: center;
}

.col-id {
    width: 55px;
    text-align: center;
    font-family: var(--font-mono);
}

.col-link {
    width: 180px;
}

.col-time {
    width: 155px;
}

.col-content {
    width: 280px;
}

.col-source {
    width: 110px;
}

.col-video {
    width: 90px;
    text-align: center;
}

.col-image {
    width: 110px;
    text-align: center;
}

.col-status {
    width: 130px;
    text-align: center;
}

.col-log {
    width: 85px;
    text-align: center;
}

.col-actions {
    width: 75px;
    text-align: center;
}

.checkbox-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-input);
    display: inline-block;
    position: relative;
    transition: all var(--transition-speed);
}

.checkbox-container:hover .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked+.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked+.checkmark:after {
    display: block;
}

.cell-editable {
    cursor: cell;
}

.cell-editable:hover {
    background: rgba(0, 0, 0, 0.01);
}

.cell-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--primary);
    background: var(--bg-card-solid);
    color: var(--text-main);
    font-family: inherit;
    font-size: inherit;
    padding: 0.65rem 0.95rem;
    box-sizing: border-box;
    outline: none;
    z-index: 5;
    box-shadow: 0 0 8px var(--primary-glow);
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: var(--radius-full);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.image-preview-container {
    display: inline-block;
    position: relative;
    cursor: pointer;
}

.img-thumbnail {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-color);
    transition: transform var(--transition-speed);
}

.img-thumbnail:hover {
    transform: scale(1.15);
}

.image-popup {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    width: 150px;
    height: 150px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    background: var(--bg-card-solid);
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: all 0.2s var(--transition-bounce);
}

.image-preview-container:hover .image-popup {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.725rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge i {
    font-size: 0.65rem;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.badge-danger {
    background: rgba(225, 29, 72, 0.1);
    color: #e11d48;
}

.badge-info {
    background: rgba(2, 132, 199, 0.1);
    color: #0284c7;
}

.select-status {
    display: none;
}

.select-status option {
    background: var(--bg-card-solid);
    color: var(--text-main);
    padding: 8px;
    text-transform: none;
    font-weight: normal;
}

/* Custom Dropdown Container (áp dụng trực tiếp cho .badge) */
.custom-dropdown-container {
    position: relative;
    cursor: pointer;
    user-select: none;
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem 0.25rem 0.85rem !important;
    transition: all var(--transition-speed);
}

.custom-dropdown-container:hover {
    opacity: 0.85;
}

.custom-dropdown-container.active,
.custom-dropdown-container.active:hover {
    opacity: 1 !important;
}

.custom-dropdown-arrow {
    transition: transform var(--transition-speed);
}

.custom-dropdown-container.active .custom-dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.custom-dropdown-menu {
    position: absolute;
    top: 125%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    min-width: 140px;
    padding: 0.35rem 0;
    margin: 0;
    list-style: none;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s var(--transition-bounce);
    text-transform: none;
}

.custom-dropdown-container.active .custom-dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Dropdown Items */
.custom-dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-main);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.custom-dropdown-item:hover {
    background-color: var(--bg-input);
    color: var(--primary);
}

.custom-dropdown-item.active {
    background-color: var(--primary-glow);
    color: var(--primary);
    font-weight: 700;
}

/* Đảm bảo menu dropdown không bị che khuất bởi ô bảng */
td.col-status {
    overflow: visible !important;
}

td.col-status:has(.custom-dropdown-container.active) {
    z-index: 100 !important;
}

.btn-log {
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
    border: 1px solid rgba(79, 70, 229, 0.15);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.725rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-log:hover {
    background: var(--primary);
    color: white;
}

.action-icon {
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-speed);
    font-size: 0.9rem;
    padding: 0.25rem;
}

.action-icon:hover {
    color: var(--danger);
}

/* ==========================================================================
   AutoPost Hub - Modals & Toast Notifications
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-box {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 650px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.12);
    transform: translateY(30px) scale(0.95);
    transition: all 0.3s var(--transition-bounce);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.modal-title i {
    color: var(--primary);
}

.modal-title i.terminal-icon {
    color: var(--success);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    transition: color var(--transition-speed);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card-solid);
    box-shadow: 0 0 8px var(--primary-glow);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.terminal-screen {
    font-family: var(--font-mono);
    font-size: 0.825rem;
    line-height: 1.6;
    color: #10b981;
    /* Keep terminal green neon */
    background: #030712;
    /* Keep terminal background dark */
    height: 320px;
    overflow-y: auto;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8);
}

.terminal-line {
    margin-bottom: 0.4rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-line .timestamp {
    color: #4b5563;
    margin-right: 0.5rem;
    font-size: 0.75rem;
}

.terminal-line .prefix {
    color: #818cf8;
    margin-right: 0.25rem;
}

.terminal-line.error {
    color: #f43f5e;
}

.terminal-line.warning {
    color: #fbbf24;
}

.terminal-line.info {
    color: #38bdf8;
}

.terminal-line.success-line {
    color: #34d399;
}

.toast-container {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 1100;
}

.toast {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    padding: 0.9rem 1.4rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(-150%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 280px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.danger {
    border-left-color: var(--danger);
}

.toast i {
    font-size: 1.1rem;
}

.toast.success i {
    color: var(--success);
}

.toast.warning i {
    color: var(--warning);
}

.toast.danger i {
    color: var(--danger);
}

/* ==========================================================================
   AutoPost Hub - Layout Structure (Sidebar + Content)
   ========================================================================== */

.app-layout {
    display: flex;
    flex: 1;
    width: 100%;
    height: calc(100vh - 70px);
    overflow: hidden;
    position: relative;
}

.app-content {
    flex: 1;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-speed) ease;
    position: relative;
    z-index: 1;
    height: calc(100vh - 68px);
}

.app-sidebar {
    width: 250px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    transition: width var(--transition-speed) ease,
        padding var(--transition-speed) ease,
        transform 0.3s ease;
    z-index: 99;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
}

.menu-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.menu-item:hover {
    background: rgba(79, 70, 229, 0.05);
    color: var(--primary);
}

.menu-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Desktop: collapsed */
.app-sidebar.collapsed {
    width: 0;
    padding: 1.5rem 0;
    overflow: hidden;
    border-right-color: transparent;
}

/* Sidebar backdrop - mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 199;
}

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

/* ==========================================================================
   AutoPost Hub - Responsive Breakpoints
   ========================================================================== */

/* ── Tablet lớn (≤ 1200px) ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .app-sidebar {
        width: 210px;
    }

    .table-wrapper {
        margin: 0 1.5rem 1.5rem 1.5rem;
    }

    .stats-container {
        padding: 1.25rem 1.5rem 0.5rem 1.5rem;
    }

    .toolbar {
        padding: 1rem 1.5rem;
    }
}

/* ── Tablet (≤ 992px) ───────────────────────────────────────────────────── */
@media (max-width: 992px) {
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem 1.25rem 0.5rem 1.25rem;
    }

    .stat-info p {
        font-size: 1.5rem;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .table-wrapper {
        margin: 0 1.25rem 1.25rem 1.25rem;
    }

    .toolbar {
        padding: 0.85rem 1.25rem;
    }

    /* Thu nhỏ sidebar trên tablet */
    .app-sidebar {
        width: 190px;
        padding: 1.25rem 0.75rem;
    }

    .menu-item span {
        font-size: 0.82rem;
    }
}

/* ── Tablet nhỏ / Mobile ngang (≤ 768px) ───────────────────────────────── */
@media (max-width: 768px) {

    /* Header */
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .header-logo h1 {
        font-size: 1.1rem;
    }

    /* Sidebar: ẩn hoàn toàn trên mobile mặc định */
    .app-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px !important;
        z-index: 200;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
        padding-top: 4.5rem;
        /* Quan trọng: ẩn khả năng tương tác khi sidebar đóng */
        pointer-events: none;
        visibility: hidden;
    }

    .app-sidebar.mobile-open {
        transform: translateX(0) !important;
        pointer-events: auto;
        visibility: visible;
    }

    /* Overlay nền tối khi sidebar mở */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 199;
        animation: fadeIn 0.2s ease;
    }

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

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Nút hamburger hiện trên mobile */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Stats container */
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 1rem 1rem 0.5rem 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-info p {
        font-size: 1.45rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Toolbar */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .search-box {
        max-width: 100%;
    }

    .btn-group {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .btn-group .btn {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }

    /* Bảng dữ liệu */
    .table-wrapper {
        margin: 0 0.75rem 1rem 0.75rem;
        border-radius: var(--radius-md);
        /* Cho phép scroll ngang */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 700px;
    }

    th,
    td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Ẩn bớt cột ít quan trọng */
    .col-log,
    .col-select {
        display: none;
    }

    /* Modal */
    .modal-box {
        width: 95%;
        margin: 0 auto;
        max-height: 85vh;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }

    /* Terminal screen */
    .terminal-screen {
        height: 240px;
        font-size: 0.75rem;
    }

    /* Toast */
    .toast-container {
        left: 50%;
        transform: translateX(-50%);
        top: 1rem;
        bottom: auto;
        align-items: center;
    }

    .toast {
        min-width: 0;
        width: 100%;
        font-size: 0.8rem;
        padding: 0.75rem 1rem;
    }
}

/* ── Mobile nhỏ (≤ 576px) ──────────────────────────────────────────────── */
@media (max-width: 576px) {

    header {
        padding: 0.6rem 0.75rem;
    }

    .header-logo h1 {
        font-size: 1rem;
    }

    .header-status {
        font-size: 0.7rem;
        padding: 0.3rem 0.65rem;
    }

    /* Stats: 1 cột */
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
        padding: 0.75rem 0.75rem 0.25rem 0.75rem;
    }

    .stat-card {
        padding: 0.85rem;
        flex-direction: row;
    }

    .stat-info h3 {
        font-size: 0.65rem;
    }

    .stat-info p {
        font-size: 1.3rem;
        margin-top: 0.1rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }

    /* Toolbar */
    .toolbar {
        padding: 0.6rem 0.75rem;
        gap: 0.6rem;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.55rem 0.9rem;
    }

    .search-box input {
        font-size: 0.82rem;
        padding: 0.6rem 1rem 0.6rem 2.4rem;
    }

    /* Bảng */
    .table-wrapper {
        margin: 0 0.5rem 0.75rem 0.5rem;
    }

    th,
    td {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Ẩn thêm cột trên màn hình rất nhỏ */
    .col-source,
    .col-time {
        display: none;
    }

    /* Modal */
    .modal-box {
        width: 100%;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 80vh;
        transform: translateY(100%);
        overflow: hidden;
    }

    .modal-overlay.active .modal-box {
        transform: translateY(0);
    }

    .modal-header {
        padding: 0.85rem 1rem;
    }

    .modal-title {
        font-size: 0.875rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* Toast */
    .toast-container {
        left: 0;
        right: 0;
        top: 0;
        bottom: auto;
        padding: 0.5rem;
        background: transparent;
        align-items: center;
    }

    .toast {
        border-radius: var(--radius-md);
    }
}

/* ==========================================================================
   AutoPost Hub - Global Action Buttons (Synced Edit / Delete Buttons)
   ========================================================================== */
.action-btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm, 6px);
    background: var(--bg-hover, #f3f4f6);
    color: var(--primary, #000);
    border: 1px solid var(--border, #e5e7eb);
    cursor: pointer;
    transition: all var(--transition-speed, 0.2s);
}

.action-btn-edit:hover {
    background: var(--primary, #000);
    color: #fff;
    border-color: var(--primary, #000);
}

.action-btn-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm, 6px);
    background: rgba(225, 29, 72, 0.05);
    color: var(--danger, #e11d48);
    border: 1px solid rgba(225, 29, 72, 0.15);
    cursor: pointer;
    transition: all var(--transition-speed, 0.2s);
}

.action-btn-delete:hover {
    background: var(--danger, #e11d48);
    color: #fff;
    border-color: var(--danger, #e11d48);
}
}