/* ==========================================================================
   IHK SEO Dashboard – Custom Styles
   Farbschema basierend auf ihk.de Corporate Design
   ========================================================================== */

/* --- IHK Color Variables --- */
:root {
    --ihk-primary: #003C71;
    --ihk-primary-dark: #002B52;
    --ihk-primary-light: #0077B6;
    --ihk-accent: #FFB81C;
    --ihk-accent-hover: #E5A300;
    --ihk-success: #007A33;
    --ihk-danger: #C8102E;
    --ihk-warning: #F0AB00;
    --ihk-info: #0077B6;
    --ihk-text: #1D1D1B;
    --ihk-text-muted: #4A4A4A;
    --ihk-bg: #F5F5F5;
    --ihk-bg-card: #FFFFFF;
    --ihk-border: #DEE2E6;
}

/* --- Base --- */
body {
    background-color: var(--ihk-bg);
    color: var(--ihk-text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

/* --- Navbar --- */
.navbar-ihk {
    background-color: var(--ihk-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 1rem;
}
.navbar-ihk .navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff !important;
    letter-spacing: 0.3px;
}
.navbar-ihk .navbar-brand span {
    color: var(--ihk-accent);
}
.navbar-ihk .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem;
    border-radius: 4px;
    transition: background-color 0.15s, color 0.15s;
}
.navbar-ihk .nav-link:hover,
.navbar-ihk .nav-link.active {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.12);
}
.navbar-ihk .dropdown-menu {
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    padding: 0.5rem 0;
}
.navbar-ihk .dropdown-menu.show {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4.5rem);
    overflow: hidden;
}
.navbar-ihk .dropdown-item {
    font-size: 0.88rem;
    padding: 0.45rem 1rem;
    color: var(--ihk-text) !important;
}
.navbar-ihk .dropdown-item:hover {
    background-color: var(--ihk-bg);
    color: var(--ihk-primary) !important;
}
.navbar-ihk .dropdown-item.active,
.navbar-ihk .dropdown-item:active {
    background-color: var(--ihk-primary);
    color: #fff !important;
}
.navbar-ihk .dropdown-header {
    color: var(--ihk-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.navbar-ihk .dashboard-switcher-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
}
.navbar-ihk .dashboard-switcher-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(50vh, 22rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.navbar-ihk .dashboard-switcher-scroll .dropdown-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Cards --- */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    background-color: var(--ihk-bg-card);
    transition: box-shadow 0.2s;
}
.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.card-header {
    background-color: var(--ihk-bg-card);
    border-bottom: 2px solid var(--ihk-bg);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--ihk-primary);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    text-align: left;
}
.card-header-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
}
.card-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
}
.card-header-actions .btn-chart-pdf {
    margin-left: 0;
}
.btn-widget-info {
    color: var(--ihk-text-muted);
    line-height: 1;
    font-size: 0.95rem;
    text-decoration: none;
}
.btn-widget-info:hover,
.btn-widget-info:focus {
    color: var(--ihk-primary);
}
.popover {
    max-width: 280px;
    font-size: 0.82rem;
}

/* --- KPI Cards --- */
.kpi-card {
    position: relative;
    text-align: center;
    padding: 1.5rem 0.75rem 1.25rem;
}
.kpi-card .btn-widget-info {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
}
.kpi-card .kpi-label {
    font-size: 0.78rem;
    color: var(--ihk-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}
.kpi-card .kpi-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--ihk-primary);
    line-height: 1.2;
}

/* --- Charts --- */
.chart-wrapper {
    position: relative;
    height: 320px;
    padding: 0.5rem;
}

/* Graph + Tabelle: feste Kartenhöhe wie rechter Nachbar; Tabelle nur innerhalb scrollen */
.chart-wrapper.widget-chart-table-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-wrapper.widget-chart-table-body .widget-graph-table-toolbar {
    flex: 0 0 auto;
}

.chart-wrapper.widget-chart-table-body .widget-graph-table-panel {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.chart-wrapper.widget-chart-table-body .widget-graph-table-panel--table {
    display: flex;
    flex-direction: column;
}

.chart-wrapper.widget-chart-table-body .widget-graph-table-panel .marketing-table-scroll {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
}

.chart-wrapper.widget-chart-table-body .widget-table-pager {
    flex: 0 0 auto;
}

/* Keep dashboard widget tables horizontally contained */
.chart-wrapper.widget-chart-table-body .marketing-table-scroll table {
    width: 100%;
    table-layout: fixed;
}

.chart-wrapper.widget-chart-table-body .marketing-table-scroll th,
.chart-wrapper.widget-chart-table-body .marketing-table-scroll td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* First column should get most space, numeric columns fixed width */
.chart-wrapper.widget-chart-table-body .marketing-table-scroll th:first-child,
.chart-wrapper.widget-chart-table-body .marketing-table-scroll td:first-child {
    width: auto;
}

.chart-wrapper.widget-chart-table-body .marketing-table-scroll th:not(:first-child),
.chart-wrapper.widget-chart-table-body .marketing-table-scroll td:not(:first-child) {
    width: 8.5rem;
    max-width: 8.5rem;
}

/* Keep numeric values consistently right-aligned */
.chart-wrapper.widget-chart-table-body .marketing-table-scroll th.text-end,
.chart-wrapper.widget-chart-table-body .marketing-table-scroll td.text-end {
    text-align: right;
}

/* Sortable header affordance */
.chart-wrapper.widget-chart-table-body .marketing-table-scroll thead th[data-sort-key] {
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.chart-wrapper.widget-chart-table-body .marketing-table-scroll thead th[data-sort-key]:hover {
    background-color: rgba(0, 60, 113, 0.08);
    color: var(--ihk-primary);
}

/* Marquee-like reveal for long text in first column */
.chart-wrapper.widget-chart-table-body .marketing-table-scroll td:first-child .cell-marquee {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.chart-wrapper.widget-chart-table-body .marketing-table-scroll td:first-child:hover .cell-marquee {
    overflow: visible;
    text-overflow: clip;
    animation: table-marquee 4s linear infinite;
}

@keyframes table-marquee {
    0% { transform: translateX(0); }
    15% { transform: translateX(0); }
    85% { transform: translateX(calc(-100% + 12rem)); }
    100% { transform: translateX(0); }
}

/* --- Buttons --- */
.btn-ihk-primary {
    background-color: var(--ihk-primary);
    border-color: var(--ihk-primary);
    color: #fff;
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: 6px;
    padding: 0.4rem 1rem;
}
.btn-ihk-primary:hover {
    background-color: var(--ihk-primary-dark);
    border-color: var(--ihk-primary-dark);
    color: #fff;
}
.btn-ihk-accent {
    background-color: var(--ihk-accent);
    border-color: var(--ihk-accent);
    color: var(--ihk-primary);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 6px;
    padding: 0.4rem 1rem;
}
.btn-ihk-accent:hover {
    background-color: var(--ihk-accent-hover);
    border-color: var(--ihk-accent-hover);
    color: var(--ihk-primary);
}
.btn-ihk-outline {
    background-color: transparent;
    border: 1.5px solid var(--ihk-primary);
    color: var(--ihk-primary);
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: 6px;
    padding: 0.4rem 1rem;
}
.btn-ihk-outline:hover {
    background-color: var(--ihk-primary);
    color: #fff;
}

/* --- Time Range Picker --- */
#timerange-picker .btn {
    border-color: var(--ihk-primary);
    color: var(--ihk-primary);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.35rem 0.9rem;
}
#timerange-picker .btn.active {
    background-color: var(--ihk-primary);
    border-color: var(--ihk-primary);
    color: #fff;
}
#timerange-picker .btn:hover:not(.active) {
    background-color: rgba(0, 60, 113, 0.08);
}

/* --- Chart export buttons --- */
.btn-chart-pdf,
.btn-chart-excel,
.btn-chart-csv {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-color: var(--ihk-border);
    color: var(--ihk-text-muted);
    border-radius: 4px;
}
.btn-chart-pdf {
    margin-left: auto;
}
.btn-chart-export {
    border-color: var(--ihk-border);
    color: var(--ihk-text-muted);
    background-color: #fff;
}
.btn-chart-excel,
.btn-chart-csv {
    margin-left: 0.35rem;
}
.btn-chart-pdf:hover,
.btn-chart-export:hover,
.btn-chart-excel:hover,
.btn-chart-csv:hover {
    background-color: var(--ihk-primary);
    border-color: var(--ihk-primary);
    color: #fff;
}

/* --- Relevance Table --- */
#relevance-table {
    font-size: 0.85rem;
}
#relevance-table thead {
    background-color: var(--ihk-primary);
    color: #fff;
}
#relevance-table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.65rem 0.75rem;
    border: none;
}
#relevance-table tbody tr {
    border-bottom: 1px solid var(--ihk-bg);
}
#relevance-table tbody tr:hover {
    background-color: rgba(0, 60, 113, 0.03);
}
#relevance-table code {
    color: var(--ihk-text-muted);
    font-size: 0.78rem;
    background: var(--ihk-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

/* --- Status Badges --- */
.badge-relevant {
    background-color: var(--ihk-success);
    color: #fff;
}
.badge-declining {
    background-color: var(--ihk-warning);
    color: var(--ihk-text);
}
.badge-low-traffic {
    background-color: var(--ihk-danger);
    color: #fff;
}
.badge-niche {
    background-color: var(--ihk-accent);
    color: var(--ihk-primary);
    font-weight: 600;
}

/* --- Funnel Details --- */
.funnel-details {
    text-align: center;
    line-height: 1.6;
    font-size: 0.82rem;
}

/* --- Login Card --- */
.login-card {
    max-width: 400px;
    margin: 0 auto;
    border-top: 4px solid var(--ihk-primary);
}
.login-card .card-title {
    color: var(--ihk-primary);
}

/* --- Section Titles --- */
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ihk-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--ihk-accent);
    display: inline-block;
}

/* --- Dashboard Header --- */
.dashboard-header {
    background: linear-gradient(135deg, var(--ihk-primary) 0%, var(--ihk-primary-light) 100%);
    color: #fff;
    padding: 1.25rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
}
.dashboard-header h2 {
    font-weight: 700;
    font-size: 1.4rem;
    margin: 0;
}
.dashboard-header .btn {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}
.dashboard-header .btn:hover {
    background-color: rgba(255,255,255,0.15);
    border-color: #fff;
}

/* --- Alerts --- */
.alert {
    border-radius: 8px;
    border: none;
    font-size: 0.88rem;
}

/* --- Footer --- */
.footer-ihk {
    color: var(--ihk-text-muted);
    font-size: 0.78rem;
    padding: 1rem 0;
    border-top: 1px solid var(--ihk-border);
    margin-top: 2rem;
}

/* --- Admin Table --- */
.admin-table thead {
    background-color: var(--ihk-primary);
    color: #fff;
}
.admin-table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    border: none;
    padding: 0.6rem 0.75rem;
}

.dashboard-list-actions-col {
    width: 1%;
    white-space: nowrap;
    vertical-align: middle;
}

.dashboard-list-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.dashboard-list-actions form {
    display: inline;
    margin: 0;
}

.dashboard-list-source-status {
    margin-top: 0;
    gap: 8px;
    font-size: 1rem;
}

/* --- Filter Select --- */
#relevance-filter {
    border-color: var(--ihk-primary);
    color: var(--ihk-primary);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 6px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chart-wrapper {
        height: 250px;
    }
    .kpi-card .kpi-value {
        font-size: 1.4rem;
    }
    .dashboard-header {
        padding: 1rem;
    }
    .dashboard-header h2 {
        font-size: 1.15rem;
    }
    #relevance-table {
        font-size: 0.78rem;
    }
}

.mgmt-summary .section-title {
    font-size: 1.35rem;
}
#mgmt-kpi-cards > [class*="col"] {
    margin-bottom: 0.75rem;
}
#mgmt-kpi-cards .kpi-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
#mgmt-kpi-cards .kpi-value {
    flex: 1 1 auto;
}
#mgmt-kpi-cards .mgmt-trend {
    min-height: 1.15em;
    margin-top: auto;
}
.mgmt-trend-placeholder {
    visibility: hidden;
}
.mgmt-chart-wrap {
    height: 220px;
}
.mgmt-trend {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.2rem;
    color: var(--ihk-text-muted);
}
.mgmt-trend.is-up {
    color: #1b7a3d;
}
.mgmt-trend.is-down {
    color: #b42318;
}
.mgmt-table {
    font-size: 0.88rem;
}
.mgmt-table thead th {
    white-space: nowrap;
}
.mgmt-table thead th[data-sort-key] {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.mgmt-table thead th[data-sort-key]:hover {
    background-color: rgba(0, 60, 113, 0.08);
    color: var(--ihk-primary);
}
.mgmt-table-total th {
    background: var(--ihk-bg);
    font-weight: 700;
}

/* --- User Voice / Feedback tab --- */
.user-voice-tab {
    position: fixed;
    left: 0;
    top: auto;
    bottom: 22%;
    z-index: 1030;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    background-color: var(--ihk-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    line-height: 1;
    text-decoration: none;
    padding: 0.55rem 0.22rem;
    border-radius: 0 5px 5px 0;
    box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.14);
    transition: background-color 0.15s, color 0.15s;
}
.user-voice-tab-label {
    display: inline-block;
    transform: rotate(180deg);
}
.user-voice-tab:hover,
.user-voice-tab:focus,
.user-voice-tab.is-active {
    background-color: var(--ihk-primary-dark);
    color: #fff;
}

body:has(.user-voice-tab) main.container-fluid {
    padding-left: 1.65rem;
}

.user-voice-hearts-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    padding: 0.85rem 1rem;
    min-width: 220px;
}
.user-voice-hearts-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ihk-text-muted);
    font-weight: 600;
}
.user-voice-hearts-row {
    display: flex;
    gap: 0.35rem;
    margin: 0.25rem 0;
    font-size: 1.25rem;
}
.user-voice-heart.is-available {
    color: var(--ihk-danger);
}
.user-voice-heart.is-spent {
    color: var(--ihk-border);
}
.user-voice-hearts-meta {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ihk-primary);
}

.user-voice-kind-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.user-voice-kind-toggles .btn {
    border-color: var(--ihk-primary);
    color: var(--ihk-primary);
    font-weight: 500;
}
.user-voice-kind-toggles .btn-check:checked + .btn {
    background-color: var(--ihk-primary);
    border-color: var(--ihk-primary);
    color: #fff;
}

.user-voice-section-heading {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ihk-primary);
    margin-bottom: 0.85rem;
}

.user-voice-item-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ihk-text);
}
.user-voice-item-body {
    white-space: pre-wrap;
    font-size: 0.92rem;
}
.user-voice-item-meta,
.user-voice-voters {
    font-size: 0.82rem;
}
.user-voice-voters-label {
    font-weight: 600;
    color: var(--ihk-text);
    margin-right: 0.25rem;
}

.user-voice-kind-badge.kind-feature {
    background-color: var(--ihk-primary);
}
.user-voice-kind-badge.kind-feedback {
    background-color: var(--ihk-info);
}
.user-voice-kind-badge.kind-bug {
    background-color: var(--ihk-danger);
}

.user-voice-vote-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 3.1rem;
    padding: 0.45rem 0.4rem;
    border: 1.5px solid var(--ihk-border);
    border-radius: 10px;
    background: #fff;
    color: var(--ihk-text-muted);
    font-weight: 700;
    line-height: 1.1;
}
button.user-voice-vote-btn:hover {
    border-color: var(--ihk-danger);
    color: var(--ihk-danger);
}
.user-voice-vote-btn.is-voted {
    border-color: var(--ihk-danger);
    background: rgba(200, 16, 46, 0.08);
    color: var(--ihk-danger);
}
.user-voice-vote-btn .fa-heart {
    font-size: 1.1rem;
    margin-bottom: 0.15rem;
}

.user-voice-status {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
}
.user-voice-status-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: #c5c9d1;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: 6px;
    transition: color 0.15s, background-color 0.15s;
}
button.user-voice-status-btn:hover {
    background: #f3f5f8;
    color: #8a93a3;
}
.user-voice-status-btn.status-ok.is-active {
    color: #0d6efd;
}
.user-voice-status-btn.status-in_progress.is-active {
    color: #fd7e14;
}
.user-voice-status-btn.status-done.is-active {
    color: #198754;
}
.user-voice-status-btn.status-archived.is-active {
    color: #8d6e4f;
}

@media (max-width: 768px) {
    .user-voice-tab {
        top: auto;
        bottom: 1.2rem;
        writing-mode: horizontal-tb;
        border-radius: 0 5px 5px 0;
        padding: 0.4rem 0.55rem;
        letter-spacing: 0.04em;
    }
    .user-voice-tab-label {
        transform: none;
    }
}
