/* ContentStudio54 - Dashboard Styles */

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #1f2231;
    --bg-input: #252836;
    --border: #2a2d3a;
    --text: #e4e6ed;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --orange: #f97316;
    --orange-bg: rgba(249, 115, 22, 0.12);
    --gray: #6b7280;
    --gray-bg: rgba(107, 114, 128, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.login-box h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-box h1 span {
    color: var(--primary);
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

input:focus, select:focus {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-input);
    color: var(--text);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-full { width: 100%; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.9; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Subnav */
.subnav {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 52px;
    z-index: 49;
}

.subnav-link {
    padding: 0.625rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.subnav-link:hover {
    color: var(--text);
}

.subnav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.topbar h1 {
    font-size: 1.125rem;
    font-weight: 700;
}

.topbar h1 span {
    color: var(--primary);
}

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

.topbar-right select {
    width: auto;
    padding: 0.375rem 0.625rem;
    font-size: 0.8rem;
}

/* Dashboard Grid */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.25rem;
    padding: 1.5rem 2rem;
    max-width: 1600px;
}

/* Project Cards */
.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s, opacity 0.15s, transform 0.15s;
    cursor: grab;
    min-width: 0;
    overflow: hidden;
}

.project-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.project-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.project-card.drag-over {
    border-color: var(--primary);
    transform: scale(1.02);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-title {
    min-width: 0;
    overflow: hidden;
}

.card-title h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
}
.site-link:hover { color: var(--primary); }

.card-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

/* Metrics */
.card-metrics {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.metric {
    text-align: center;
    padding: 0.5rem 0.25rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.metric-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.metric-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.125rem;
}

.metric-exit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(239, 68, 68, 0.2);
}
.metric-exit-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ef4444;
    font-variant-numeric: tabular-nums;
}
.metric-exit-label {
    font-size: 0.6rem;
    color: #ef4444;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.8;
}

.metric-posts-total {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-variant-numeric: tabular-nums;
}

.metric-ctr-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
}
.metric-ctr-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.metric-ctr-label {
    font-size: 0.6rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.8;
}

/* Feature Badges */
.card-features {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-yellow { background: var(--yellow-bg);  color: var(--yellow); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray); }
.badge-red    { background: var(--red-bg);     color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }

/* Chart area */
.card-chart {
    margin-bottom: 0.5rem;
}

.card-chart canvas {
    width: 100% !important;
    height: 120px !important;
}

/* Click Breakdown */
.card-clicks {
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

.card-clicks-title {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

.card-clicks-total {
    font-weight: 400;
    opacity: 0.7;
    text-transform: none;
    letter-spacing: 0;
}

.click-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.click-item-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.click-item-bar-wrap {
    width: 60px;
    flex-shrink: 0;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.click-item-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.click-item-count {
    flex-shrink: 0;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    min-width: 24px;
    text-align: right;
}

/* Pipeline */
.card-pipeline {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pipeline-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 0.75rem;
    margin-top: 0.25rem;
}

.pipeline-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pipeline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden { display: none !important; }
.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

/* Plugin Install Bar */
.plugin-install-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.plugin-install-bar input {
    flex: 1;
}

/* Plugin List */
.plugin-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.plugin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.plugin-info {
    flex: 1;
    min-width: 0;
}

.plugin-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.plugin-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.plugin-status {
    flex-shrink: 0;
    margin-left: 0.75rem;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Deploy Modal */
.deploy-modal-content {
    max-width: 580px;
}

#deploy-form input[type="email"] {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

#deploy-form input[type="email"]:focus {
    border-color: var(--primary);
}

/* Deploy Steps */
.deploy-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.deploy-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: all 0.3s;
}

.deploy-step .step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.3s;
}

.deploy-step .step-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deploy-step.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.deploy-step.active .step-icon {
    background: var(--primary);
    color: #fff;
    animation: step-pulse 1.5s ease-in-out infinite;
}

.deploy-step.done {
    color: var(--green);
}

.deploy-step.done .step-icon {
    background: var(--green);
    color: #fff;
}

.deploy-step.failed {
    color: var(--red);
}

.deploy-step.failed .step-icon {
    background: var(--red);
    color: #fff;
}

@keyframes step-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Deploy Log */
.deploy-log {
    background: #0d0f14;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.7rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.deploy-log pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Deploy Result */
.deploy-success-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.deploy-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--green-bg);
    color: var(--green);
    font-size: 1.25rem;
    font-weight: 700;
    flex-shrink: 0;
}

.deploy-success-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.deploy-credentials {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.credential-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.credential-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 80px;
    flex-shrink: 0;
}

.credential-value {
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.credential-value a {
    color: var(--primary);
    text-decoration: none;
}

.credential-value a:hover {
    text-decoration: underline;
}

.credential-secret {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
}

.btn-copy {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.btn-copy.copied {
    color: var(--green);
    border-color: var(--green);
}

.deploy-result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Deploy error state */
.deploy-error {
    padding: 1rem;
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .topbar {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .topbar-left { flex: 1 0 auto; }

    .topbar-right {
        flex-wrap: wrap;
        gap: 0.375rem;
        width: 100%;
    }

    .topbar-right select {
        flex: 1;
        min-width: 0;
    }

    .subnav {
        padding: 0 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .subnav::-webkit-scrollbar { display: none; }

    .subnav-link {
        padding: 0.625rem 0.875rem;
        white-space: nowrap;
    }

    .card-metrics {
        grid-template-columns: repeat(6, 1fr);
    }
    .card-metrics > *:nth-child(-n+3) {
        grid-column: span 2;
    }
    .card-metrics > *:nth-child(n+4) {
        grid-column: span 3;
    }

    .card-actions {
        gap: 0.25rem;
    }

    .card-actions .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .topbar h1 { font-size: 1rem; }

    /* Tokens & Docs ausblenden auf kleinen Screens */
    .topbar-right a.btn-ghost {
        display: none;
    }
    .topbar-right a.btn-ghost:last-child {
        display: inline-flex; /* Abmelden immer sichtbar */
    }
}

/* Chart Tooltip */
.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--bg-card, #1a1d27);
    border: 1px solid var(--border, #2a2d3a);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text, #e4e6ed);
    z-index: 9999;
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
    transition: opacity 0.15s;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.chart-tooltip.visible {
    opacity: 1;
}
.chart-tooltip strong {
    color: var(--text-muted, #8b8fa3);
    font-weight: 500;
}

.project-card .card-chart canvas {
    cursor: crosshair !important;
}
.project-card .card-chart {
    cursor: crosshair;
}
