/**
 * RankBotAI Admin Styles
 * Common styles for dashboard, settings, history, sidebar panels
 */

/* ========================================
   Design Tokens
   ======================================== */
:root {
    /* Primary */
    --rb-primary: #4f46e5;
    --rb-primary-hover: #4338ca;
    --rb-primary-light: #eef2ff;
    --rb-primary-ring: rgba(99, 102, 241, 0.1);

    /* Accent */
    --rb-accent: #7c3aed;
    --rb-accent-light: #f5f3ff;

    /* Semantic */
    --rb-success: #10b981;
    --rb-success-bg: #ecfdf5;
    --rb-success-text: #065f46;
    --rb-warning: #f59e0b;
    --rb-warning-bg: #fffbeb;
    --rb-warning-text: #92400e;
    --rb-danger: #ef4444;
    --rb-danger-bg: #fef2f2;
    --rb-danger-text: #991b1b;
    --rb-info: #3b82f6;
    --rb-info-bg: #eff6ff;
    --rb-info-text: #1e40af;

    /* Neutrals */
    --rb-text-primary: #111827;
    --rb-text-secondary: #6b7280;
    --rb-text-muted: #9ca3af;
    --rb-bg: #f9fafb;
    --rb-bg-card: #ffffff;
    --rb-border: #e5e7eb;
    --rb-border-light: #f3f4f6;

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

    /* Radius */
    --rb-radius-sm: 6px;
    --rb-radius: 8px;
    --rb-radius-lg: 12px;
    --rb-radius-xl: 16px;
    --rb-radius-full: 9999px;

    /* Transitions */
    --rb-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --rb-transition-spring: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    /* Font */
    --rb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --rb-font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

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

@keyframes rbFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes rbScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rbSlideInRight {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.rb-animate {
    animation: rbFadeInUp 0.4s var(--rb-transition-spring) both;
}

.rb-animate-delay-1 { animation-delay: 0.05s; }
.rb-animate-delay-2 { animation-delay: 0.1s; }
.rb-animate-delay-3 { animation-delay: 0.15s; }
.rb-animate-delay-4 { animation-delay: 0.2s; }
.rb-animate-delay-5 { animation-delay: 0.25s; }
.rb-animate-delay-6 { animation-delay: 0.3s; }

.rb-animate-fade {
    animation: rbFadeIn 0.3s ease both;
}

.rb-animate-scale {
    animation: rbScaleIn 0.3s var(--rb-transition-spring) both;
}

.rb-animate-slide-right {
    animation: rbSlideInRight 0.4s var(--rb-transition-spring) both;
}

/* ========================================
   Admin Bar Styles
   ======================================== */
@keyframes spin {
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

.rankbot-view-history {
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ========================================
   Dashboard / Settings Wrapper
   ======================================== */
.rankbot-settings-wrap {
    max-width: 98%;
    margin-top: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin-right: 20px;
}

/* Header */
.rankbot-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 15px;
    margin-top: 10px;
}

.rankbot-subtitle {
    color: #6b7280;
    font-size: 14px;
}

/* Notice fix */
.rankbot-settings-wrap .notice {
    margin-left: 0 !important;
}

.rankbot-balance-badge {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dbeafe;
}

.rankbot-topup-btn {
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 11px;
    margin-left: 8px;
    transition: background 0.2s;
}

.rankbot-topup-btn:hover {
    background: #1d4ed8;
    color: #fff;
}

/* Layout */
.rankbot-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 1200px) {
    .rankbot-grid {
        grid-template-columns: 2fr 1fr;
    }
}

@media (max-width: 1000px) {
    .rankbot-grid {
        grid-template-columns: 1fr;
    }
}

.rankbot-main-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ========================================
   Cards
   ======================================== */
.rankbot-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.rankbot-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rankbot-card-title .dashicons {
    color: #6366f1;
}

/* ========================================
   History Table
   ======================================== */
.rankbot-history-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    table-layout: fixed;
}

.rankbot-history-table thead th {
    background: #f9fafb;
    color: #4b5563;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.rankbot-history-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    color: #374151;
    vertical-align: middle;
}

.rankbot-history-table tbody tr:last-child td {
    border-bottom: none;
}

.rankbot-history-table tbody tr:hover {
    background: #f9fafb;
}

/* ========================================
   Sidebar Panel (Metabox)
   ======================================== */
.rankbot-sidebar-panel {
    margin-top: 5px;
}

.rankbot-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    color: #2271b1;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    text-decoration: none;
}

.rankbot-sidebar-btn:hover {
    background: #f0f7ff;
    border-color: #2271b1;
    color: #2271b1;
}

.rankbot-sidebar-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 6px;
}

.rankbot-btn-primary {
    background: #f6f7f7;
    border-color: #2271b1;
    color: #2271b1;
    font-weight: 600;
}

.rankbot-btn-cost {
    background: #f0f0f1;
    color: #646970;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
}

.rankbot-stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
}

.rankbot-stat-label {
    color: #646970;
}

.rankbot-stat-value {
    font-weight: 600;
    color: #1d2327;
}

/* Score Ring */
.rankbot-score-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    margin: 0 auto 8px;
}

/* ========================================
   Toolbar (Classic Editor)
   ======================================== */
.rankbot-wrapper {
    margin: 20px 0;
}

.rankbot-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.rankbot-toolbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rankbot-toolbar-title {
    font-weight: 700;
    font-size: 15px;
    color: #1e293b;
}

.rankbot-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rankbot-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rankbot-action-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.rankbot-action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rankbot-badge-cost {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 600;
}

/* ========================================
   Gradient Animation
   ======================================== */
@keyframes rankbotGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ========================================
   Dashboard Page Styles
   ======================================== */
.rankbot-wrap {
    margin: 10px 20px 0 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.rankbot-dashboard-container {
    width: 100%;
    max-width: 100%;
    margin-top: 10px;
}

.rankbot-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.rankbot-title {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rankbot-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.rankbot-status-connected {
    background: #dcfce7;
    color: #166534;
}

.rankbot-status-disconnected {
    background: #fee2e2;
    color: #991b1b;
}

/* ========================================
   Form Elements
   ======================================== */
.rankbot-form-row {
    margin-bottom: 16px;
}

.rankbot-form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
    font-size: 13px;
}

.rankbot-form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.rankbot-form-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ========================================
   Buttons
   ======================================== */
.rankbot-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
}

.rankbot-button-primary {
    background: #4f46e5;
    color: #fff;
}

.rankbot-button-primary:hover {
    background: #4338ca;
    color: #fff;
}

.rankbot-button-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.rankbot-button-secondary:hover {
    background: #e5e7eb;
}

/* ========================================
   Badges & Pills
   ======================================== */
.rankbot-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
}

.rankbot-badge-success {
    background: #dcfce7;
    color: #166534;
}

.rankbot-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.rankbot-badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.rankbot-badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ========================================
   Spinner
   ======================================== */
.rankbot-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========================================
   Dashboard Page Additional Styles
   ======================================== */
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-active {
    background: #ecfdf5;
    color: #047857;
}

.status-active .status-dot {
    background: #10b981;
}

.status-inactive {
    background: #f3f4f6;
    color: #4b5563;
}

.status-inactive .status-dot {
    background: #9ca3af;
}

/* Stats Grid */
.rankbot-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Gradient for Balance */
.stat-card.primary {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
}

.stat-card.primary .stat-label {
    color: rgba(255,255,255, 0.9);
}

.stat-card.primary .stat-value {
    color: white;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
}

.stat-icon {
    float: right;
    opacity: 0.1;
    transform: scale(1.5);
}

/* Detail Table */
.details-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

.details-table td {
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}

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

.details-label {
    color: #6b7280;
    font-weight: 500;
    width: 200px;
}

.details-value {
    color: #111827;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

/* Buttons */
.rankbot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid transparent;
    gap: 6px;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
    color: white;
    transform: translateY(-1px);
}

.btn-danger {
    background: #fff;
    color: #ef4444;
    border: 1px solid #fea5a5;
}

.btn-danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #ef4444;
}

.btn-text {
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 0;
}

.btn-text:hover {
    color: #111827;
}

/* Card Header */
.rankbot-card-header {
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

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

/* ========================================
   Toast Notifications
   ======================================== */
#rb-toast-container {
    position: fixed;
    top: 44px; /* Below WP admin bar */
    right: 20px;
    z-index: 160000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 420px;
    width: 100%;
}

.rb-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--rb-radius-lg, 12px);
    background: var(--rb-bg-card, #fff);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--rb-border-light, #f3f4f6);
    pointer-events: auto;
    transform: translateX(110%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
    font-family: var(--rb-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-size: 14px;
    line-height: 1.4;
}

.rb-toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.rb-toast-leaving {
    transform: translateX(110%);
    opacity: 0;
}

.rb-toast-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.rb-toast-message {
    flex: 1;
    color: var(--rb-text-primary, #111827);
    font-weight: 500;
}

.rb-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--rb-text-muted, #9ca3af);
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}

.rb-toast-close:hover {
    color: var(--rb-text-primary, #111827);
}

/* Toast type accents */
.rb-toast-success {
    border-left: 3px solid var(--rb-success, #10b981);
}

.rb-toast-error {
    border-left: 3px solid var(--rb-danger, #ef4444);
}

.rb-toast-warning {
    border-left: 3px solid var(--rb-warning, #f59e0b);
}

.rb-toast-info {
    border-left: 3px solid var(--rb-info, #3b82f6);
}

/* ========================================
   Activation Required Hero Screen
   ======================================== */
.rankbot-activation-hero {
    position: relative;
    text-align: center;
    padding: 80px 40px;
    max-width: 640px;
    margin: 60px auto;
    background: var(--rb-bg-card);
    border-radius: var(--rb-radius-xl);
    box-shadow: var(--rb-shadow-lg);
    overflow: hidden;
    animation: rbScaleIn 0.5s var(--rb-transition-spring) both;
}
.rankbot-activation-glow {
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    pointer-events: none;
}
.rankbot-activation-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--rb-primary), var(--rb-accent));
    border-radius: var(--rb-radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 28px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3);
}
.rankbot-activation-icon .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #fff;
}
.rankbot-activation-hero h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--rb-text-primary);
    margin: 0 0 12px;
}
.rankbot-activation-hero > p {
    font-size: 16px;
    color: var(--rb-text-secondary);
    line-height: 1.6;
    max-width: 440px;
    margin: 0 auto 36px;
}
.rankbot-activation-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 400px;
    margin: 0 auto 36px;
}
.rankbot-activation-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--rb-primary-light);
    border-radius: var(--rb-radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--rb-primary);
}
.rankbot-activation-feature .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}
.rankbot-activation-btn {
    padding: 14px 36px !important;
    font-size: 16px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}
.rankbot-activation-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}
.rankbot-activation-sub {
    margin-top: 20px !important;
    font-size: 13px !important;
    color: var(--rb-text-muted) !important;
}
