@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sidebar-bg: #0c0e14;
    --sidebar-hover: #1a1f2e;
    --sidebar-active: #1e2436;
    --accent: #75dab4;
    --accent-dark: #5bc49e;
    --accent-glow: rgba(117, 218, 180, 0.15);
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1a1d26;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --info: #3b82f6;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { color: var(--accent); }

/* Layout */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo-link {
    display: block;
    line-height: 0;
}

.sidebar-logo {
    height: 32px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.sidebar-brand small {
    display: block;
    color: #6b7280;
    font-size: 10px;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #4b5563;
    padding: 16px 12px 8px;
    font-weight: 600;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #9ca3af;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 500;
    transition: all .15s ease;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #e5e7eb;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: .7;
}

.sidebar-nav a.active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer .btn-logout {
    width: 100%;
    padding: 10px;
    background: rgba(255,255,255,.06);
    color: #9ca3af;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
}

.sidebar-footer .btn-logout:hover {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
    border-color: rgba(239,68,68,.3);
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.topbar-logo-link {
    display: none;
    line-height: 0;
}

.topbar-logo {
    height: 28px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 28px; flex: 1; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 { font-size: 16px; font-weight: 600; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 8px;
    letter-spacing: -1px;
}

.stat-card .stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all .15s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, #1a1d26, #2d3348);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2d3348, #3d4563);
    color: #fff;
    transform: translateY(-1px);
}

.btn-accent {
    background: var(--accent);
    color: #0c0e14;
}

.btn-accent:hover {
    background: var(--accent-dark);
    color: #0c0e14;
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: #e5e7eb; color: var(--text); }

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent-dark); }

/* Tables */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    background: #fafbfc;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

tr:hover td { background: #fafbfc; }

.table-actions { display: flex; gap: 8px; align-items: center; }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.badge-published { background: #d1fae5; color: #065f46; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-unread { background: #dbeafe; color: #1e40af; }

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
    border-color: var(--danger);
}

.field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}

.checkbox-label input { width: auto; }

/* Service sections in Google settings */
.service-block {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    background: #fafbfc;
}

.service-block h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Media grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.media-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow .15s;
}

.media-item:hover { box-shadow: var(--shadow); }

.media-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.media-item-info { padding: 10px; }

.media-item-info .filename {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.media-picker img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .15s;
}

.media-picker img:hover { border-color: var(--accent); }

/* Connection status */
.connection-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.connection-item {
    flex: 1;
    min-width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.connection-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(16,185,129,.5); }
.connection-dot.offline { background: var(--danger); }

.connection-item strong { font-size: 13px; display: block; }
.connection-item span { font-size: 12px; color: var(--text-muted); }

/* Quick actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: all .15s;
}

.quick-action:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    color: var(--text);
}

.quick-action .qa-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-dark);
    font-size: 18px;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    margin-top: 20px;
    justify-content: center;
}

.pagination li a,
.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--text);
}

.pagination li.active span {
    background: var(--accent);
    color: #0c0e14;
    border-color: var(--accent);
    font-weight: 700;
}

.pagination li a:hover { background: #f3f4f6; }

.pagination li.disabled span { color: #d1d5db; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }

/* Message detail */
.message-preview {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
    font-size: 13px;
}

.message-unread td { background: #eff6ff !important; font-weight: 600; }

/* Mobile */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    top: -200px;
    right: -100px;
    pointer-events: none;
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    color: #fff;
    position: relative;
    z-index: 1;
}

.login-left h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.2;
}

.login-left h1 span { color: var(--accent); }

.login-left p {
    color: #9ca3af;
    margin-top: 16px;
    font-size: 16px;
    max-width: 400px;
    line-height: 1.6;
}

.login-features {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #d1d5db;
    font-size: 14px;
}

.login-feature .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.login-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: #fff;
}

.login-card { width: 100%; max-width: 360px; }

.login-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

@media (max-width: 900px) {
    .login-left { display: none; }
    .login-right { width: 100%; }
}

/* Permissions grid */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.permission-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
}
.permission-module {
    margin-bottom: 24px;
    padding: 0 24px;
}
.permission-module h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Kanban board */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 24px;
    min-height: 400px;
}
.kanban-column {
    flex: 0 0 280px;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.kanban-column-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.kanban-cards {
    padding: 12px;
    min-height: 200px;
}
.kanban-cards.drag-over {
    background: var(--accent-glow);
}
.kanban-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    box-shadow: var(--shadow);
}
.kanban-card.dragging { opacity: 0.5; }
.kanban-card small { display: block; color: var(--text-muted); margin-top: 4px; }
.kanban-card-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent-dark);
}

/* Activity timeline */
.activity-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item.completed { opacity: 0.6; }
.activity-type {
    font-size: 11px;
    text-transform: uppercase;
    background: var(--accent-glow);
    color: var(--accent-dark);
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Lead score badges */
.badge.score-hot { background: #fef2f2; color: #dc2626; }
.badge.score-warm { background: #fffbeb; color: #d97706; }
.badge.score-cold { background: #eff6ff; color: #2563eb; }
