/* ==================== CSS Variables & Reset ==================== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-hover: #252838;
    --bg-input: #252838;
    --border-color: #2e3144;
    --text-primary: #e4e6f0;
    --text-secondary: #9ca0b0;
    --text-muted: #6b7080;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.12);
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.12);
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ==================== Login Page ==================== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1117 0%, #1a1040 50%, #0f1117 100%);
    position: relative;
    overflow: hidden;
}

.login-body::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    top: -200px;
    right: -200px;
    animation: float 8s ease-in-out infinite;
}

.login-body::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 70%);
    bottom: -100px;
    left: -100px;
    animation: float 6s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: rgba(30, 33, 48, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    margin-bottom: 16px;
    animation: fadeIn 0.5s ease;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper svg {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
}

.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ==================== App Layout ==================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

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

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent-hover);
}

.nav-item.active svg {
    stroke: var(--accent-hover);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 4px;
}

.user-avatar, .user-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--danger) !important;
}

.logout-btn:hover {
    background: var(--danger-bg) !important;
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-header {
    height: var(--header-height);
    padding: 0 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
}

.content-area {
    padding: 28px;
}

/* ==================== Cards ==================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* ==================== Stats Grid ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

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

/* ==================== Quick Actions ==================== */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.quick-action-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-hover);
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #818cf8, #8b5cf6);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

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

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

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

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

/* ==================== Tables ==================== */
.table-responsive {
    overflow-x: auto;
}

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

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.data-table tr:hover {
    background: var(--bg-hover);
}

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

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-btns {
    display: flex;
    gap: 6px;
}

/* ==================== Badges ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-yellow { background: var(--warning-bg); color: var(--warning); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: var(--bg-hover); color: var(--text-muted); }

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.required { color: var(--danger); }

input[type="text"], input[type="password"], input[type="url"], input[type="email"],
textarea, select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

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

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

select {
    cursor: pointer;
}

.file-input {
    padding: 8px;
}

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

.form-row {
    display: flex;
    gap: 16px;
}

.inline-form .form-row {
    align-items: flex-end;
}

.form-action {
    flex: 0;
    margin-bottom: 16px;
}

.form-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
}

/* ==================== Product Grid ==================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.product-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--bg-hover);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.product-info {
    padding: 16px;
}

.product-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.product-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.product-actions {
    display: flex;
    gap: 6px;
}

/* ==================== Product Detail ==================== */
.header-actions {
    display: flex;
    gap: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

.detail-section h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--accent-hover);
}

.detail-field {
    display: flex;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    width: 120px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
}

.detail-value {
    flex: 1;
    font-size: 14px;
}

.detail-image img {
    width: 100%;
    border-radius: var(--radius-sm);
}

.link {
    color: var(--accent);
    word-break: break-all;
}

/* ==================== Q&A Section ==================== */
.qa-form {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.qa-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qa-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    gap: 16px;
    transition: var(--transition);
}

.qa-item:hover {
    border-color: var(--accent);
}

.qa-content {
    flex: 1;
}

.qa-question, .qa-answer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.qa-question svg { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.qa-answer svg { color: var(--success); flex-shrink: 0; margin-top: 2px; }

.qa-keywords {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    padding-left: 24px;
}

/* ==================== AI Test ==================== */
.ai-reply-box {
    margin-top: 16px;
    padding: 16px;
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
}

.ai-reply-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
}

.ai-reply-content {
    font-size: 14px;
    line-height: 1.6;
}

/* ==================== Alerts ==================== */
.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* ==================== Utilities ==================== */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-wrap { max-width: 200px; word-break: break-word; }

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.empty-state-large {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.empty-state-large svg {
    margin-bottom: 12px;
    opacity: 0.3;
}

.current-image {
    margin-bottom: 8px;
}

/* ==================== Thumb Upload Widget ==================== */
.thumb-upload-wrap {
    position: relative;
    display: inline-block;
}

.thumb-upload-box {
    width: 180px;
    height: 160px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.thumb-upload-box:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.thumb-upload-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 20px;
    position: relative;
    z-index: 1;
    transition: var(--transition);
}

.thumb-upload-trigger:hover {
    color: var(--accent);
}

.thumb-upload-trigger svg {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: var(--transition);
}

.thumb-upload-trigger:hover svg {
    color: var(--accent);
}

.thumb-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    z-index: 2;
}

.thumb-link-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    z-index: 3;
}

.thumb-link-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.thumb-url-popover {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.2s ease;
}

.thumb-url-popover input {
    flex: 1;
    min-width: 0;
}

.thumb-preview {
    width: 180px;
    height: 160px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
}

.thumb-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    backdrop-filter: blur(4px);
}

.thumb-preview:hover .thumb-remove-btn {
    opacity: 1;
}

.thumb-remove-btn:hover {
    background: var(--danger);
    transform: scale(1.1);
}

/* ==================== Animations ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card, .product-card {
    animation: fadeIn 0.3s ease;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .form-row {
        flex-direction: column;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .products-grid {
        grid-template-columns: 1fr;
    }
}
