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

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #4A4DE7;
    --primary-dark: #3D3FC7;
    --primary-light: #6C6FF1;
    --primary-bg: #EEEDFD;
    --blue: #4A90E2;
    --green: #2ECC71;
    --cyan: #00C9E0;
    --amber: #F5A623;
    --red: #E74C3C;
    --bg-main: #F0F2F5;
    --bg-white: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --text-dark: #1A1D2E;
    --text-medium: #5A607F;
    --text-light: #8B92A5;
    --border: #E4E7EC;
    --border-light: #F0F1F3;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 240px;
}
html { font-size: 14px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD2DE; border-radius: 3px; }

/* ─── Auth Pages ─── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4A4DE7 0%, #6C6FF1 50%, #8B8FF5 100%);
    padding: 20px;
}
.auth-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.auth-logo {
    width: 56px; height: 56px;
    border-radius: 14px;
    margin: 0 auto 16px;
    display: block;
    box-shadow: 0 4px 16px rgba(74,77,231,0.3);
}
.auth-title {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 32px;
}

/* ─── Top Header ─── */
.top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(74,77,231,0.3);
}
.top-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}
.top-header .brand img {
    width: 32px; height: 32px;
    border-radius: 8px;
}
.top-header .user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
    font-weight: 500;
}
.top-header .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    width: var(--sidebar-w);
    height: calc(100vh - 56px);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 99;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-top: 8px;
}
.sidebar.open { transform: translateX(0); }
.sidebar-menu { flex: 1; padding: 4px 12px; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-medium);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    margin-bottom: 2px;
}
.menu-item:hover {
    background: var(--primary-bg);
    color: var(--primary);
}
.menu-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(74,77,231,0.3);
}
.menu-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.menu-section {
    padding: 16px 14px 6px;
    font-size: 0.65rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
}
.menu-divider { border-top: 1px solid var(--border-light); margin: 8px 12px; }
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    flex-shrink: 0;
}
.sidebar-footer .menu-item { color: var(--red); }
.sidebar-footer .menu-item:hover { background: #FDF0EF; }

/* Backdrop */
.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 98;
}
.backdrop.show { display: block; }

/* Menu button */
.menu-btn {
    position: fixed;
    top: 10px; left: 10px;
    z-index: 200;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.menu-btn:hover { background: rgba(255,255,255,0.25); }

/* ─── Main Content ─── */
.main-content {
    margin-left: 0;
    padding: 24px;
    padding-top: 80px;
    max-width: 1400px;
}
@media (min-width: 768px) {
    .sidebar { transform: translateX(0); }
    .backdrop { display: none !important; }
    .main-content { margin-left: var(--sidebar-w); }
    .menu-btn { display: none; }
}

/* ─── Page Header ─── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-dark);
}

/* ─── Cards ─── */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-header {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dark);
}

/* ─── Stat Cards ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .info { flex: 1; }
.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.stat-card .value {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}
.stat-card .icon-area {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-card.blue .value { color: var(--blue); }
.stat-card.blue .icon-area { background: #EBF5FF; }
.stat-card.green .value { color: var(--green); }
.stat-card.green .icon-area { background: #EAFAF1; }
.stat-card.cyan .value { color: var(--cyan); }
.stat-card.cyan .icon-area { background: #E8FAFC; }
.stat-card.amber .value { color: var(--amber); }
.stat-card.amber .icon-area { background: #FEF5E7; }
.stat-card.red .value { color: var(--red); }
.stat-card.red .icon-area { background: #FDEDEC; }
.stat-card.purple .value { color: var(--primary); }
.stat-card.purple .icon-area { background: var(--primary-bg); }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}
th {
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #FAFBFC;
}
tr:hover td { background: #F8F9FB; }

/* ─── Buttons ─── */
.btn {
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(74,77,231,0.3); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #27AE60; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #C0392B; }
.btn-warning { background: var(--amber); color: #fff; }
.btn-secondary { background: var(--bg-white); color: var(--text-medium); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; border-radius: 6px; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-medium);
    margin-bottom: 6px;
    font-weight: 600;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="file"],
select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,77,231,0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-light); }
textarea { min-height: 120px; resize: vertical; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ─── Alerts ─── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid;
}
.alert-success { background: #EAFAF1; border-color: #D5F5E3; color: #1E8449; }
.alert-danger { background: #FDEDEC; border-color: #FADBD8; color: #C0392B; }
.alert-warning { background: #FEF5E7; border-color: #FDEBD0; color: #D68910; }
.alert-info { background: #E8FAFC; border-color: #D1F2EB; color: #148F77; }

/* ─── Badges ─── */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.badge-success { background: #EAFAF1; color: #1E8449; }
.badge-danger { background: #FDEDEC; color: #C0392B; }
.badge-warning { background: #FEF5E7; color: #D68910; }
.badge-info { background: #E8FAFC; color: #148F77; }
.badge-default { background: var(--primary-bg); color: var(--primary); }

/* ─── Editor ─── */
.editor-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-white);
}
.editor-pane, .preview-pane { overflow: hidden; display: flex; flex-direction: column; }
.editor-label {
    padding: 8px 14px;
    background: #FAFBFC;
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.editor-pane textarea {
    flex: 1;
    width: 100%;
    border: none;
    resize: none;
    padding: 14px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    background: #FAFBFC;
    color: var(--text-dark);
    line-height: 1.6;
    border-radius: 0;
}
.editor-pane textarea:focus { box-shadow: none; }
.preview-pane iframe { flex: 1; width: 100%; border: none; background: #fff; }
@media (max-width: 768px) {
    .editor-wrap { grid-template-columns: 1fr; height: auto; }
    .editor-pane, .preview-pane { height: 300px; }
}

/* ─── Toolbar ─── */
.toolbar {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar button {
    padding: 6px 12px;
    background: #FAFBFC;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-medium);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: all 0.15s;
}
.toolbar button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* ─── Toggle ─── */
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .slider {
    position: absolute; inset: 0;
    background: #CBD5E0;
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s;
}
.toggle .slider:before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider:before { transform: translateX(20px); }

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-light);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state .title { font-size: 1rem; font-weight: 600; color: var(--text-medium); margin-bottom: 6px; }
.empty-state .desc { font-size: 0.85rem; margin-bottom: 20px; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .page-header h1 { font-size: 1.25rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card .value { font-size: 1.5rem; }
    .card { padding: 16px; }
    .main-content { padding: 16px; padding-top: 72px; }
}

/* ─── Enhanced Responsive ─── */
/* Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .sidebar { width: 200px; }
    :root { --sidebar-w: 200px; }
    .main-content { margin-left: 200px; }
    .menu-item { padding: 9px 10px; font-size: 0.8rem; gap: 8px; }
    .menu-icon { width: 18px; font-size: 0.9rem; }
}

/* Mobile */
@media (max-width: 768px) {
    .top-header { padding: 0 16px; height: 52px; }
    .top-header .brand { font-size: 1rem; }
    .top-header .brand img { width: 28px; height: 28px; }
    .main-content { padding: 16px; padding-top: 68px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header h1 { font-size: 1.3rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .value { font-size: 1.4rem; }
    .stat-card .icon-area { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 10px; }
    .card { padding: 16px; border-radius: 10px; }
    .btn { padding: 8px 14px; font-size: 0.8rem; }
    .btn-lg { padding: 10px 20px; font-size: 0.9rem; }
    .auth-card { padding: 32px 24px; margin: 16px; }
    .auth-logo { width: 48px; height: 48px; }
    .auth-title { font-size: 1.4rem; }
    table { font-size: 0.8rem; }
    th, td { padding: 10px 12px; }
    .editor-wrap { grid-template-columns: 1fr; height: auto; }
    .editor-pane, .preview-pane { height: 280px; }
    .toolbar { gap: 4px; padding: 8px; }
    .toolbar button { padding: 5px 8px; font-size: 0.75rem; }
}

/* Small phones */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card .label { font-size: 0.7rem; }
    .stat-card .value { font-size: 1.2rem; }
    .stat-card .icon-area { width: 36px; height: 36px; font-size: 1rem; }
    .page-header h1 { font-size: 1.15rem; }
    .main-content { padding: 12px; padding-top: 64px; }
    .top-header { height: 48px; }
    .top-header .user-area span { display: none; }
    .auth-card { padding: 28px 20px; border-radius: 12px; }
    .form-group { margin-bottom: 12px; }
    .card { padding: 14px; margin-bottom: 14px; }
}

/* Large desktop */
@media (min-width: 1400px) {
    .main-content { max-width: 1600px; }
    .stats-grid { grid-template-columns: repeat(5, 1fr); }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .auth-wrapper { padding: 10px; }
    .auth-card { padding: 20px; max-width: 360px; }
    .auth-logo { width: 36px; height: 36px; margin-bottom: 8px; }
    .auth-title { font-size: 1.1rem; margin-bottom: 2px; }
    .auth-subtitle { margin-bottom: 16px; font-size: 0.75rem; }
}
