/* AI SEO Content Engine - Main Stylesheet */

/* ==========================================
   CSS Variables / Design Tokens
   ========================================== */
:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --primary-bg: rgba(79, 70, 229, 0.08);
    --secondary: #0ea5e9;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: rgba(79, 70, 229, 0.2);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;

    --transition: all 0.2s ease;
}

/* ==========================================
   Global Resets
   ========================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--primary-dark);
}

/* ==========================================
   Sidebar
   ========================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.5rem;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    white-space: nowrap;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 0 0.75rem;
}

.sidebar-heading {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 1rem 0.75rem 0.5rem;
    margin-top: 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    color: var(--text-sidebar);
    border-radius: var(--radius);
    margin-bottom: 2px;
    font-size: 0.85rem;
    font-weight: 450;
    transition: var(--transition);
}

.sidebar-nav .nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.sidebar-nav .nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1rem;
    text-align: center;
    opacity: 0.7;
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
    color: var(--primary-light);
}

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

/* ==========================================
   Top Bar
   ========================================== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

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

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

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.breadcrumb {
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: '›';
    color: var(--text-muted);
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

/* ==========================================
   Content Area
   ========================================== */
.content-wrapper {
    padding: 1.5rem;
}

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

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.card-body {
    padding: 1.25rem;
}

/* ==========================================
   Stat Cards
   ========================================== */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.stat-card-icon.primary { background: var(--primary-bg); color: var(--primary); }
.stat-card-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-card-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-card-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.stat-card-icon.info { background: rgba(6, 182, 212, 0.1); color: var(--info); }
.stat-card-icon.accent { background: rgba(139, 92, 246, 0.1); color: var(--accent); }

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.stat-card-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================
   Tables
   ========================================== */
.table {
    font-size: 0.85rem;
}

.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom-width: 2px;
    border-color: var(--border);
    padding: 0.75rem;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-color: var(--border-light);
}

.table-hover tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.02);
}

/* ==========================================
   Badges
   ========================================== */
.badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

/* ==========================================
   Forms
   ========================================== */
.form-control,
.form-select {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==========================================
   Flash Messages / Alerts
   ========================================== */
.alert {
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: none;
    padding: 0.85rem 1.25rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger, .alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: #155e75;
    border-left: 4px solid var(--info);
}

/* ==========================================
   Empty State
   ========================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

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

.empty-state h5 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

/* ==========================================
   Pagination
   ========================================== */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ==========================================
   Login Page
   ========================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.login-logo h4 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.login-logo p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ==========================================
   Activity List
   ========================================== */
.activity-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.activity-dot.auth { background: var(--info); }
.activity-dot.project { background: var(--primary); }
.activity-dot.keyword { background: var(--success); }
.activity-dot.article { background: var(--accent); }
.activity-dot.settings { background: var(--warning); }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.activity-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ==========================================
   User dropdown
   ========================================== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--bg-body);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
}

.user-info {
    text-align: left;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* ==========================================
   Filter bar
   ========================================== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filter-bar .form-control,
.filter-bar .form-select {
    max-width: 200px;
    font-size: 0.82rem;
    padding: 0.45rem 0.65rem;
}

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

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

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

    .btn-sidebar-toggle {
        display: inline-block;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1039;
    }

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

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1rem;
    }

    .stat-card-value {
        font-size: 1.35rem;
    }

    .filter-bar .form-control,
    .filter-bar .form-select {
        max-width: 100%;
    }
}

/* ==========================================
   Installer
   ========================================== */
.installer-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    padding: 2rem;
}

.installer-card {
    width: 100%;
    max-width: 640px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

.check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}

.check-pass {
    color: var(--success);
    font-weight: 600;
}

.check-fail {
    color: var(--danger);
    font-weight: 600;
}

/* ==========================================
   Utilities
   ========================================== */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.82rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
