/* =============================================================================
   ADMIN COMMON STYLES - n9 Agents Design System
   ============================================================================= */

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

:root {
    /* Beautiful Modern Color Palette */
    --color-bg: #f8f6f3;
    --color-bg-warm: #fdfbf9;
    --color-bg-cool: #f5f7fa;
    --color-surface: #ffffff;
    --color-surface-hover: #fefefe;

    /* Text Colors */
    --color-text: #272727;
    --color-text-secondary: #5c5c5c;
    --color-text-muted: #8a8a8a;
    --color-text-light: #b0b0b0;

    /* Accent Colors - Blue/Teal Gradient */
    --color-accent: #79a7ed;
    --color-accent-blue: #79a7ed;
    --color-accent-teal: #80c3b9;
    --color-accent-hover: #5a8fd9;
    --color-accent-gradient: linear-gradient(135deg, #79a7ed 0%, #80c3b9 100%);

    /* Status Colors */
    --color-success: #6db89f;
    --color-success-bg: rgba(109, 184, 159, 0.1);
    --color-warning: #e4b363;
    --color-warning-bg: rgba(228, 179, 99, 0.1);
    --color-danger: #d4726a;
    --color-danger-bg: rgba(212, 114, 106, 0.1);
    --color-info: #79a7ed;
    --color-info-bg: rgba(121, 167, 237, 0.1);

    /* Borders */
    --color-border: rgba(39, 39, 39, 0.08);
    --color-border-light: rgba(39, 39, 39, 0.04);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(39, 39, 39, 0.04);
    --shadow-sm: 0 2px 8px rgba(39, 39, 39, 0.06);
    --shadow-md: 0 4px 16px rgba(39, 39, 39, 0.08);
    --shadow-lg: 0 8px 32px rgba(39, 39, 39, 0.1);
    --shadow-accent: 0 4px 20px rgba(121, 167, 237, 0.25);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: all 0.15s ease;
    --transition-base: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Legacy compatibility */
    --primary: #272727;
    --accent: #79a7ed;
    --accent-hover: #5a8fd9;
    --success: #6db89f;
    --warning: #e4b363;
    --error: #d4726a;
    --danger: #d4726a;
    --info: #79a7ed;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;
    --radius: 10px;
    --shadow: var(--shadow-sm);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-primary);
    font-size: 13px;
    background: linear-gradient(165deg, #fdfbf9 0%, #f8f5f2 50%, #f5f0ec 100%);
    background-attachment: fixed;
    color: var(--color-text);
    line-height: 1.5;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* Background gradient orbs */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(121, 167, 237, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(128, 195, 185, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* =============================================================================
   TOPBAR
   ============================================================================= */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-back {
    color: var(--color-text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    transition: var(--transition-fast);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.topbar-back:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.topbar-title {
    color: var(--color-text);
    font-size: 14px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-btn {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: var(--transition-fast);
    font-family: var(--font-primary);
}

.topbar-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-accent);
}

.topbar-btn svg {
    width: 14px;
    height: 14px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    background: var(--color-accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-accent);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */
.sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--color-surface);
    height: calc(100vh - 52px);
    position: fixed;
    left: 0;
    top: 52px;
    z-index: 90;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-section {
    padding: 8px 12px;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 6px;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav a,
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 2px 8px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    cursor: pointer;
}

.sidebar-nav a:hover,
.nav-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.sidebar-nav a.active,
.nav-item.active {
    background: var(--color-info-bg);
    color: var(--color-accent);
}

.sidebar-nav svg,
.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--color-accent);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */
.main {
    margin-left: 220px;
    margin-top: 52px;
    padding: 20px;
    min-height: calc(100vh - 52px);
    position: relative;
    z-index: 1;
}

.main.no-sidebar {
    margin-left: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.page-subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* =============================================================================
   CARDS
   ============================================================================= */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.card-body {
    padding: 16px;
}

.card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

/* =============================================================================
   STAT CARDS
   ============================================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.stat-icon.blue { background: var(--color-info-bg); color: var(--color-accent); }
.stat-icon.green { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon.yellow { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-icon.red { background: var(--color-danger-bg); color: var(--color-danger); }

.stat-icon svg {
    width: 18px;
    height: 18px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.stat-label {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.stat-change {
    font-size: 11px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up { color: var(--color-success); }
.stat-change.down { color: var(--color-danger); }

/* =============================================================================
   BUTTONS
   ============================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-primary);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg {
    width: 14px;
    height: 14px;
}

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

.btn-primary:hover {
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
    border-color: var(--color-accent);
}

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

.btn-success:hover {
    background: #5fa88d;
}

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

.btn-danger:hover {
    background: #c45f58;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: 6px 10px;
}

.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.btn-sm svg {
    width: 12px;
    height: 12px;
}

.btn-lg {
    padding: 10px 20px;
    font-size: 14px;
}

/* =============================================================================
   TABLES
   ============================================================================= */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
}

th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

td {
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
}

tr:hover td {
    background: var(--color-bg-warm);
}

.table-actions {
    display: flex;
    gap: 4px;
}

/* =============================================================================
   FORMS
   ============================================================================= */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
    font-family: var(--font-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-info-bg);
}

.form-control::placeholder {
    color: var(--color-text-light);
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238a8a8a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.form-help {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* =============================================================================
   BADGES & STATUS
   ============================================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.badge-neutral {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

/* =============================================================================
   MODALS
   ============================================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(39, 39, 39, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: var(--transition-base);
}

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

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(85vh - 130px);
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--color-bg);
}

/* =============================================================================
   EMPTY STATES
   ============================================================================= */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--color-text-light);
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

/* =============================================================================
   LOADING & SPINNERS
   ============================================================================= */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* =============================================================================
   TOASTS
   ============================================================================= */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
    border-left: 3px solid var(--color-accent);
}

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

.toast-message {
    font-size: 12px;
    color: var(--color-text);
    flex: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =============================================================================
   SEARCH
   ============================================================================= */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 36px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

/* =============================================================================
   TABS
   ============================================================================= */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 16px;
}

.tab {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
}

.tab:hover {
    color: var(--color-text);
}

.tab.active {
    color: var(--color-accent);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-accent);
    border-radius: 2px 2px 0 0;
}

/* =============================================================================
   DROPDOWN
   ============================================================================= */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 6px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: var(--transition-fast);
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--color-text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.dropdown-item svg {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

.dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 6px 0;
}

/* =============================================================================
   UTILITIES
   ============================================================================= */
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-muted { color: var(--color-text-muted) !important; }

.bg-success { background: var(--color-success-bg) !important; }
.bg-warning { background: var(--color-warning-bg) !important; }
.bg-danger { background: var(--color-danger-bg) !important; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.hidden { display: none !important; }

/* =============================================================================
   LAYOUT - APP SHELL
   ============================================================================= */
.app {
    display: flex;
    min-height: 100vh;
    padding-top: 56px;
}

/* =============================================================================
   SIDEBAR TOGGLE (mobile)
   ============================================================================= */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.sidebar-toggle:hover {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 89;
}

.sidebar-overlay.visible {
    display: block;
}

/* =============================================================================
   NAV SECTIONS (sidebar groups)
   ============================================================================= */
.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title,
.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 6px;
}

.nav-menu {
    padding: 16px 0;
}

.nav-item i,
.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    text-align: center;
    font-size: 14px;
}

/* =============================================================================
   FORM ALIASES (agents use both .form-control and .form-input)
   ============================================================================= */
.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--font-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-info-bg);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-light);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-row-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* =============================================================================
   CARD EXTRAS
   ============================================================================= */
.card-body.np {
    padding: 0;
}

/* =============================================================================
   GRID LAYOUTS
   ============================================================================= */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* =============================================================================
   STAT ICON EXTRA COLORS
   ============================================================================= */
.stat-icon.purple {
    background: rgba(124, 58, 237, 0.1);
    color: #7c3aed;
}

.stat-icon.orange {
    background: rgba(234, 88, 12, 0.1);
    color: #ea580c;
}

/* =============================================================================
   ACTION BUTTONS (table row actions)
   ============================================================================= */
.actions {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.action-btn.delete:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

/* =============================================================================
   TABLE EXTRAS
   ============================================================================= */
th {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.3px;
}

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

.cell-title {
    font-weight: 500;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =============================================================================
   BADGE VARIANTS (semantic status badges)
   ============================================================================= */
.badge-published,
.badge-active,
.badge-paid,
.badge-completed {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-draft,
.badge-inactive,
.badge-pending {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.badge-scheduled,
.badge-processing {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.badge-overdue,
.badge-failed,
.badge-cancelled {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

/* =============================================================================
   SECTIONS / VIEWS (SPA page switching)
   ============================================================================= */
.section,
.view {
    display: none;
}

.section.active,
.view.active {
    display: block;
}

/* =============================================================================
   LIST ITEMS (settings lists, item rows)
   ============================================================================= */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
}

.list-item-actions {
    display: flex;
    gap: 8px;
}

/* =============================================================================
   UPLOAD ZONE
   ============================================================================= */
.upload-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.upload-zone:hover {
    border-color: var(--color-accent);
    background: var(--color-info-bg);
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--color-text-muted);
}

.upload-text {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.upload-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* =============================================================================
   AI CARD (AI generate prompt area)
   ============================================================================= */
.ai-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.ai-icon {
    width: 48px;
    height: 48px;
    background: var(--color-accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.ai-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.ai-subtitle {
    color: var(--color-text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

/* =============================================================================
   CHAT WIDGET (floating chat)
   ============================================================================= */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 150;
}

.chat-toggle {
    width: 56px;
    height: 56px;
    background: var(--color-accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-accent);
    border: none;
    transition: var(--transition-fast);
}

.chat-toggle:hover {
    transform: scale(1.05);
}

.chat-toggle svg {
    width: 24px;
    height: 24px;
    color: white;
}

.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    display: none;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.chat-window.active {
    display: flex;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-message {
    margin-bottom: 12px;
    max-width: 85%;
}

.chat-message.user {
    margin-left: auto;
}

.chat-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.chat-message.user .chat-message-content {
    background: var(--color-accent-gradient);
    color: white;
}

.chat-message.assistant .chat-message-content {
    background: var(--color-bg);
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-primary);
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.chat-send {
    padding: 10px 16px;
    background: var(--color-accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-send:hover {
    box-shadow: var(--shadow-accent);
}

/* =============================================================================
   LOADING OVERLAY (full page loader)
   ============================================================================= */
.loading-overlay {
    position: fixed;
    top: 56px;
    left: 250px;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.loading-overlay.active {
    display: flex;
}

/* =============================================================================
   SETTINGS SECTIONS
   ============================================================================= */
.settings-section {
    margin-bottom: 32px;
}

.settings-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.api-status.configured {
    background: var(--color-success-bg);
    border: 1px solid var(--color-success);
}

.api-status.not-configured {
    background: var(--color-danger-bg);
    border: 1px solid var(--color-danger);
}

.api-status svg {
    width: 20px;
    height: 20px;
}

.api-status.configured svg { color: var(--color-success); }
.api-status.not-configured svg { color: var(--color-danger); }

/* =============================================================================
   SCHEDULE CARDS
   ============================================================================= */
.schedule-list {
    display: grid;
    gap: 12px;
}

.schedule-card {
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-accent);
}

.schedule-card.inactive {
    opacity: 0.6;
    border-left-color: var(--color-text-muted);
}

.schedule-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.schedule-meta {
    color: var(--color-text-muted);
    font-size: 12px;
}

/* =============================================================================
   CREATE BUTTON (sidebar CTA)
   ============================================================================= */
.create-btn {
    margin: 16px 12px;
    padding: 10px 16px;
    background: var(--color-accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    font-size: 13px;
    font-family: var(--font-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
    width: calc(100% - 24px);
}

.create-btn:hover {
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

/* =============================================================================
   SKILL TAGS
   ============================================================================= */
.skill-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-info-bg);
    color: var(--color-accent);
    border-radius: var(--radius-full);
    font-size: 12px;
    margin: 4px;
}

.skill-tag .remove {
    cursor: pointer;
    opacity: 0.6;
}

.skill-tag .remove:hover {
    opacity: 1;
}

/* =============================================================================
   QUILL EDITOR OVERRIDES
   ============================================================================= */
.editor-container {
    margin-bottom: 16px;
}

.ql-toolbar {
    border-color: var(--color-border) !important;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--color-bg);
}

.ql-container {
    border-color: var(--color-border) !important;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    min-height: 250px;
}

.ql-editor {
    font-size: 13px;
    font-family: var(--font-primary);
}

/* =============================================================================
   UTILITIES (extended)
   ============================================================================= */
.mb-0 { margin-bottom: 0; }
.mr-1 { margin-right: 8px; }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0; }
.w-full { width: 100%; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1200px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 95;
    }

    .sidebar.open,
    .sidebar.visible {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar-toggle {
        display: flex;
    }

    .loading-overlay {
        left: 0;
    }

    .chat-window {
        width: calc(100vw - 40px);
        right: -10px;
    }

    .form-row,
    .form-row-2,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}
