/* Terminplaner – Custom Styles */

/* Allgemein */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Poll-Tabelle */
.poll-table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border: none;
}

.poll-table {
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 0;
}

.poll-table th,
.poll-table td {
    white-space: nowrap;
    vertical-align: middle;
    border: 1px solid #dee2e6;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.poll-table tbody tr:not(#newVoteRow) td {
    padding-top: 0.08rem;
    padding-bottom: 0.08rem;
}

.poll-table .action-col {
    border: 1px solid transparent !important;
    background: transparent !important;
}

.poll-table thead th.participant-col {
    border: 1px solid transparent !important;
    background: transparent !important;
}

.poll-table tfoot .action-col {
    border: 1px solid transparent !important;
    background: transparent !important;
}

.poll-table tfoot td.participant-col {
    border: 1px solid transparent !important;
    background: transparent !important;
}

.poll-table tfoot td {
    background: transparent !important;
    border: 1px solid transparent !important;
}

.poll-table .participant-col {
    white-space: nowrap;
    min-width: 140px;
    border-right: 2px solid #dee2e6;
}

.poll-table tbody .participant-col .participant-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.poll-table thead th {
    background: #fff;
}

.poll-table .option-col {
    min-width: 50px;
    text-align: center;
}

.poll-table .text-header-col {
    word-break: normal;
    overflow-wrap: normal;
}

/* Stimmen-Farben */
.vote-cell {
    cursor: default;
    transition: background-color 0.15s;
}

.vote-yes, .vote-cell.vote-yes {
    background-color: #d4edda !important;
}

.vote-no, .vote-cell.vote-no {
    background-color: #f8d7da !important;
}

.vote-maybe, .vote-cell.vote-maybe {
    background-color: #fff3cd !important;
}

.vote-icon {
    font-size: 1.1rem;
    font-weight: bold;
}

.vote-icon.vote-yes { color: #198754; }
.vote-icon.vote-no { color: #dc3545; }
.vote-icon.vote-maybe { color: #ffc107; }

/* Vote-Button-Gruppe (Neu + Bearbeiten) */
.vote-btn-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 1px;
}

.vote-btn {
    width: 36px;
    height: 22px;
    border: 1px solid #ccc;
    border-radius: 0;
    background: #fff;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    line-height: 1;
    transition: all 0.15s;
    padding: 0;
    color: #999;
}

.vote-btn + .vote-btn {
    border-top: none;
}

.vote-btn:first-child {
    border-radius: 4px 4px 0 0;
}

.vote-btn:last-child {
    border-radius: 0 0 4px 4px;
}

.vote-btn:only-child {
    border-radius: 4px;
}

.vote-btn:hover {
    filter: brightness(0.9);
}

.vote-btn.active.vote-btn-yes {
    background-color: #198754;
    border-color: #198754;
    color: #fff;
}

.vote-btn.active.vote-btn-maybe {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}

.vote-btn.active.vote-btn-no {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

/* Summenzeile */
.sum-cell {
    font-weight: bold;
}

/* Sortierbare Optionen */
.sortable-options .option-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    transition: box-shadow 0.15s;
}

.sortable-options .option-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sortable-options .option-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.option-item .drag-handle {
    cursor: grab;
    color: #6c757d;
    margin-right: 0.5rem;
}

/* Kommentare */
.comment-card {
    border-left: 3px solid var(--bs-primary, #0d6efd);
}

/* Edit-Button in Tabelle */
.edit-vote-btn,
.delete-vote-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 0.65rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.participant-col .edit-vote-btn {
    float: right;
}

/* Bearbeiten-Modus Zeile */
tr.editing {
    background-color: #e8f4fd !important;
}

tr.editing td {
    background-color: #e8f4fd !important;
}

tr.editing td.vote-yes,
tr.editing td.vote-no,
tr.editing td.vote-maybe,
tr.editing td.vote-cell {
    background-color: #e8f4fd !important;
}

/* Neue Stimme Zeile */
#newVoteRow {
    background-color: #e8f4fd !important;
}

#newVoteRow td {
    background-color: #e8f4fd !important;
}

/* Poll-Info-Box */
.poll-info-box {
    font-size: 0.95rem;
    line-height: 1.5;
}


/* Navbar */
.navbar-brand img {
    max-height: 50px;
}

.navbar .nav-link {
    color: #333 !important;
    font-weight: 500;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.25rem;
    transition: background-color 0.15s, color 0.15s;
}

.navbar .nav-link:hover {
    color: var(--bs-primary) !important;
    background-color: rgba(0,0,0,0.05);
}

.navbar .nav-link.active {
    color: var(--bs-primary) !important;
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .poll-table .participant-col {
        border-right: 1px solid #dee2e6;
        font-size: 0.8rem;
    }

    .poll-table .participant-col input.form-control {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    .option-col {
        min-width: 55px !important;
        font-size: 0.75rem;
    }

    .poll-table {
        min-width: 400px;
    }

    .btn-group-sm .btn {
        padding: 0.2rem 0.4rem;
    }

    h2 {
        font-size: 1.4rem;
    }
}

/* Sortierbare Tabellenspalten */
th.sortable:hover {
    background-color: rgba(0,0,0,0.05);
}

/* Copy-Link Tooltip */
.copy-link-btn.copied {
    color: #198754;
    border-color: #198754;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Alert-Animationen */
.alert {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Ergebnisgrafik */
.chart-wrapper {
    display: flex;
    align-items: stretch;
    padding: 10px 0;
}

.chart-y-axis {
    display: flex;
    flex-direction: column-reverse;
    justify-content: space-between;
    height: 200px;
    padding-right: 8px;
    font-size: 0.8rem;
    color: #666;
    text-align: right;
    min-width: 30px;
}

.chart-y-axis span {
    position: relative;
    top: -0.5em;
}

.chart-bars-area {
    flex: 1;
    position: relative;
    height: 200px;
    border-left: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
}

.chart-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed #ddd;
}

.chart-bars-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 100%;
    padding: 0 10px;
    position: relative;
    z-index: 1;
}

.chart-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 80px;
}

.chart-bar-stack {
    width: 40px;
    display: flex;
    flex-direction: column-reverse;
    cursor: pointer;
    position: relative;
}

.chart-bar-yes {
    background-color: #198754;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s ease;
}

.chart-bar-maybe {
    background-color: #ffc107;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s ease;
}

/* Wenn Vielleicht über Ja liegt: Ja unten nicht abrunden */
.chart-bar-yes:not(:last-child) {
    border-radius: 0;
}

.chart-x-labels {
    display: flex;
    justify-content: space-around;
    margin-left: 30px;
    padding: 0 10px;
    margin-top: 6px;
}

.chart-bar-label {
    flex: 1;
    max-width: 80px;
    font-size: 0.75rem;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
}

.chart-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    display: none;
    margin-bottom: 4px;
    z-index: 10;
    text-align: left;
    line-height: 1.4;
}

.chart-bar-stack:hover .chart-tooltip {
    display: block;
}

/* Custom Code Feedback */
#customCodeFeedback.text-success { color: #198754 !important; }
#customCodeFeedback.text-danger { color: #dc3545 !important; }

/* Druckansicht */
@media print {
    @page {
        size: landscape;
        margin: 0.5cm;
    }

    /* Header und Footer ausblenden */
    nav.navbar,
    footer {
        display: none !important;
    }

    /* Body-Padding entfernen */
    body {
        padding-top: 0 !important;
        background-color: #fff !important;
    }

    /* Container volle Breite */
    .container {
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Kommentar-Formular ausblenden */
    .comment-form-card {
        display: none !important;
    }

    /* Buttons ausblenden (aber nicht Balken-Hintergründe) */
    .edit-vote-btn,
    .action-col,
    .copy-link-btn,
    #submitVoteBtn,
    #newVoteRow,
    #duplicateNameWarning,
    #helpModal,
    #showChartBtn,
    .poll-info-box .btn,
    .comment-form-card .btn,
    a.btn {
        display: none !important;
    }

    /* Tabelle voll anzeigen */
    .poll-table-wrapper {
        overflow: visible !important;
    }

    .poll-table {
        min-width: auto !important;
    }

    /* Grafik-Balken druckbar machen */
    .chart-bar-yes, .chart-bar-maybe, .chart-bars-area, .chart-grid-line {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Grafik sichtbar lassen wenn geöffnet */
    #chartContainer {
        display: block !important;
    }

    /* Tooltip beim Drucken ausblenden */
    .chart-tooltip {
        display: none !important;
    }

    /* Kein Schatten */
    .card, .shadow-lg {
        box-shadow: none !important;
    }
}
