/* === DESIGN TOKENS (mirrors blog-portfolio main.css) === */
:root {
    --primary: #2a6bff;
    --primary-light: #e6eeff;
    --primary-dark: #1a56d8;
    --secondary: #00c4cc;
    --accent: #ff7d45;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #1a1a1a;
    --text-light: #666;
    --text-lighter: #999;
    --bg: #ffffff;
    --bg-light: #f8f9fa;
    --bg-dark: #0f172a;
    --border: #e0e0e0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    --transition: all 0.15s ease;
    --sidebar-w: 260px;
}

[data-theme="dark"] {
    --primary: #16DB93;
    --primary-light: rgba(22, 219, 147, 0.1);
    --primary-dark: #14c483;
    --secondary: #EFCA08;
    --accent: #E94560;
    --success: #16DB93;
    --danger: #E94560;
    --warning: #EFCA08;
    --text: #F0F0F0;
    --text-light: #c8c8c8;
    --text-lighter: #a0a0a0;
    --bg: #1A1A2E;
    --bg-light: #242438;
    --bg-dark: #121224;
    --border: #2d2d45;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* === RESET === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
}

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

img {
    max-width: 100%;
    height: auto;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    line-height: 1.2;
}

/* === TYPOGRAPHY === */
.gradient-text {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === LAYOUT === */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.page-body {
    padding: 2rem;
    flex: 1;
}

/* === SIDEBAR === */
.sidebar-logo {
    padding: 1.75rem 1.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-logo-text {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-logo-sub {
    color: #666;
    font-size: 0.7rem;
    font-weight: 400;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-section-label {
    color: #555;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.75rem 1.5rem 0.375rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: #9ca3af;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(22, 219, 147, 0.08);
    border-left-color: var(--primary);
}

[data-theme="light"] .nav-item.active {
    background: rgba(42, 107, 255, 0.1);
    border-left-color: var(--primary);
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.api-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.api-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

.api-dot.offline {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {

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

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.api-label {
    color: #666;
    font-size: 0.72rem;
    font-weight: 500;
}

.api-url {
    color: #999;
    font-size: 0.68rem;
    margin-top: 2px;
    word-break: break-all;
}

/* === TOPBAR === */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.theme-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.mobile-sidebar-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.mobile-sidebar-btn:hover {
    background: var(--bg-light);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.88rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: white;
}

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

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

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

.btn-danger:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    color: white;
}

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

.btn-success:hover {
    opacity: 0.85;
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

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

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

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.stat-icon.blue {
    background: rgba(42, 107, 255, 0.1);
    color: var(--primary);
}

.stat-icon.teal {
    background: rgba(0, 196, 204, 0.1);
    color: var(--secondary);
}

.stat-icon.orange {
    background: rgba(255, 125, 69, 0.1);
    color: var(--accent);
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.375rem;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    color: var(--text-lighter);
}

/* === CARDS === */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-subtitle {
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    color: var(--text-lighter);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

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

tbody tr:hover {
    background: var(--bg-light);
}

td {
    padding: 0.85rem 1rem;
    color: var(--text);
    vertical-align: middle;
}

.table-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-lighter);
}

.table-empty i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    gap: 0.25rem;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

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

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

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

.badge-neutral {
    background: var(--bg-light);
    color: var(--text-light);
    border: 1px solid var(--border);
}

/* === MODALS === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

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

.modal {
    background: var(--bg);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    transform: scale(0.95) translateY(-10px);
    transition: transform 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-lg {
    max-width: 650px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-lighter);
    cursor: pointer;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* === FORMS === */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-lighter);
    margin-top: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(42, 107, 255, 0.12);
}

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

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

.form-input.error {
    border-color: var(--danger);
}

/* === SEARCH / FILTER === */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.45rem 0.85rem;
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary);
    background: var(--bg);
}

.search-bar i {
    color: var(--text-lighter);
    font-size: 0.85rem;
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.88rem;
    width: 200px;
}

.search-bar input::placeholder {
    color: var(--text-lighter);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-header-sub {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

/* === TOASTS === */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.1rem;
    margin-top: 1px;
    flex-shrink: 0;
}

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

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

.toast-info .toast-icon {
    color: var(--primary);
}

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

.toast-body {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.88rem;
}

.toast-message {
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-lighter);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.2rem;
    flex-shrink: 0;
}

/* === LOADING SKELETON === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-light) 25%, var(--border) 50%, var(--bg-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* === VENDOR CHIPS === */
.vendor-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.vendor-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.vendor-chip .chip-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
}

.vendor-chip .chip-remove:hover {
    opacity: 1;
}

/* === CONFIRM DIALOG === */
.confirm-dialog .modal {
    max-width: 380px;
}

.confirm-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

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

.confirm-text {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.confirm-title {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    opacity: 0.25;
    margin-bottom: 1rem;
    display: block;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-light);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

/* === QUICK ACTION CARDS === */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.quick-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
}

.quick-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    color: var(--text);
}

.quick-card-icon {
    font-size: 1.5rem;
    color: var(--primary);
}

.quick-card-label {
    font-size: 0.85rem;
    font-weight: 600;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .mobile-sidebar-btn {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

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

    .page-body {
        padding: 1rem;
    }
}

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

    .search-bar input {
        width: 130px;
    }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}
