/* ===== WPAA Dashboard — Premium Dark Mode Design ===== */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #171728;
    --bg-card: #1e1e35;
    --bg-card-hover: #252545;
    --bg-input: #13132a;
    --border: #2a2a4a;
    --border-focus: #6c5ce7;
    --text-primary: #e8e8f0;
    --text-secondary: #9090b0;
    --text-muted: #606080;
    --accent: #6c5ce7;
    --accent-hover: #7d6ff0;
    --accent-glow: rgba(108, 92, 231, 0.25);
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --blue: #3498db;
    --purple: #9b59b6;
    --gold: #f1c40f;
    --sidebar-width: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

.hidden {
    display: none !important;
}

/* ===== LOGIN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1040 50%, #0f0f1a 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow), 0 0 80px var(--accent-glow);
    animation: fadeIn 0.5s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.logo-icon.small {
    font-size: 28px;
    margin-bottom: 0;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 3px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== FORM ELEMENTS ===== */
.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
}

.input-group 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='%239090b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.error-text {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

.divider {
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.1);
}

.btn-accent {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
}

.btn-accent:hover {
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-full {
    width: 100%;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    border-radius: var(--radius);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== LAYOUT ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(108, 92, 231, 0.08);
}

.nav-item.active {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 2px 12px var(--accent-glow);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h2 {
    font-size: 20px;
    font-weight: 700;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info span {
    color: var(--text-secondary);
    font-size: 13px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
}

.content-area {
    padding: 28px 32px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

.card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.card-header {
    margin-bottom: 24px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue {
    background: rgba(52, 152, 219, 0.15);
}

.stat-icon.green {
    background: rgba(46, 204, 113, 0.15);
}

.stat-icon.purple {
    background: rgba(155, 89, 182, 0.15);
}

.stat-icon.gold {
    background: rgba(241, 196, 15, 0.15);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    display: block;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* API Keys */
.api-keys-form {
    margin-bottom: 24px;
}

.service-desc {
    color: var(--text-muted);
    font-size: 13px;
    margin: -8px 0 16px 0;
    padding: 6px 12px;
    background: rgba(108, 92, 231, 0.06);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

/* API Status Grid */
.api-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.api-status-card {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    transition: var(--transition);
}

.api-status-card.configured {
    border-color: rgba(46, 204, 113, 0.4);
    background: rgba(46, 204, 113, 0.05);
}

.api-status-card.not-configured {
    opacity: 0.7;
}

.api-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
}

.api-status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
}

.api-status-badge.active {
    background: rgba(46, 204, 113, 0.2);
    color: var(--success);
}

.api-status-badge.inactive {
    background: rgba(241, 196, 15, 0.15);
    color: var(--warning);
}

.api-status-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.apikey-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    transition: var(--transition);
}

.apikey-item:hover {
    border-color: var(--accent);
}

.apikey-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.apikey-service {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--accent-glow);
    color: var(--accent);
}

.apikey-masked {
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.apikey-actions {
    display: flex;
    gap: 8px;
}

/* Toggles */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.toggle-row label {
    font-size: 14px;
    font-weight: 500;
}

.toggle {
    width: 44px;
    height: 24px;
    appearance: none;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.toggle::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.toggle:checked {
    background: var(--accent);
}

.toggle:checked::before {
    transform: translateX(20px);
    background: #fff;
}

/* Settings Groups */
.setting-group {
    margin-bottom: 8px;
}

.setting-group h4 {
    font-size: 16px;
    margin-bottom: 16px;
}

/* Pipeline */
.pipeline-stages {
    margin-bottom: 24px;
}

.stage {
    padding: 12px 16px;
    background: var(--bg-input);
    border-left: 3px solid var(--accent);
    margin-bottom: 8px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.workflow-status {
    margin-bottom: 24px;
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.idle {
    background: rgba(144, 144, 176, 0.15);
    color: var(--text-muted);
}

.status-badge.running {
    background: rgba(52, 152, 219, 0.15);
    color: var(--blue);
    animation: pulse 1.5s infinite;
}

.status-badge.success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.status-badge.error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
}

.help-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 16px;
}

/* Logs */
.logs-container {
    max-height: 500px;
    overflow-y: auto;
}

.log-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.log-item .log-time {
    color: var(--text-muted);
    margin-right: 12px;
}

.log-item .log-level {
    font-weight: 700;
    margin-right: 8px;
}

.log-item .log-level.INFO {
    color: var(--blue);
}

.log-item .log-level.ERROR {
    color: var(--danger);
}

.log-item .log-level.WARN {
    color: var(--warning);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

tr:hover td {
    background: rgba(108, 92, 231, 0.04);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 14px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow);
    max-width: 400px;
}

.toast.success {
    background: var(--success);
    color: #fff;
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

.toast.info {
    background: var(--blue);
    color: #fff;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .top-bar {
        padding: 16px 20px;
    }

    .content-area {
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }
}