/* Trumbowyg Table Context Toolbar Styles */

.trumbowyg-table-toolbar {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1070; /* Höher als Bootstrap Modal */
    font-size: 14px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .trumbowyg-table-toolbar {
        background: #2a2a2a;
        border-color: #444;
        color: #fff;
    }
}

/* Toolbar Groups */
.trumbowyg-table-toolbar .ttb-group {
    display: inline-block;
    vertical-align: middle;
}

/* Separator */
.trumbowyg-table-toolbar .ttb-separator {
    display: inline-block;
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 5px;
    vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
    .trumbowyg-table-toolbar .ttb-separator {
        background: #555;
    }
}

/* Toolbar Buttons */
.ttb-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 4px 8px;
    margin: 0 2px;
    cursor: pointer;
    color: #333;
    font-size: 16px;
    transition: all 0.2s;
    vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
    .ttb-btn {
        color: #ccc;
    }
}

.ttb-btn:hover {
    background: #f0f0f0;
    border-color: #ddd;
}

@media (prefers-color-scheme: dark) {
    .ttb-btn:hover {
        background: #3a3a3a;
        border-color: #555;
    }
}

.ttb-btn:active {
    background: #e0e0e0;
}

/* Danger Button */
.ttb-btn-danger:hover {
    background: #fee;
    border-color: #fcc;
    color: #d00;
}

@media (prefers-color-scheme: dark) {
    .ttb-btn-danger:hover {
        background: #4a2a2a;
        border-color: #633;
        color: #f66;
    }
}

/* Color Input Styling */
#ttb-cell-bg-color,
#ttb-border-color {
    position: absolute;
    visibility: hidden;
    width: 0;
    height: 0;
}

/* Bootstrap Icons fallback */
.ttb-btn i {
    font-style: normal;
    line-height: 1;
}

/* Animation */
.trumbowyg-table-toolbar {
    animation: fadeIn 0.2s ease-in-out;
}

/* Sicherstellen dass Toolbar über anderen Elementen liegt */
.trumbowyg-box {
    position: relative;
}

/* Zusätzlicher Abstand wenn Toolbar unter der Tabelle ist */
.trumbowyg-table-toolbar.below-table {
    margin-top: 5px;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .trumbowyg-table-toolbar {
        padding: 3px;
    }
    
    .ttb-btn {
        padding: 3px 6px;
        font-size: 14px;
    }
}

/* Farbpaletten Styles */
.ttb-color-palette {
    position: absolute;
    top: 40px;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1071;
    width: 220px;
    max-height: 280px;
    overflow-y: auto;
}

@media (prefers-color-scheme: dark) {
    .ttb-color-palette {
        background: #2a2a2a;
        border-color: #444;
    }
}

/* Farb-Buttons in der Palette */
.ttb-color-btn {
    width: 18px;
    height: 18px;
    margin: 2px;
    border: 1px solid #ddd;
    border-radius: 2px;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    transition: transform 0.1s;
}

.ttb-color-btn:hover {
    transform: scale(1.2);
    border-color: #333;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Custom Color Button */
.ttb-color-custom {
    width: 40px;
    height: 18px;
    margin: 2px;
    border: 1px solid #ddd;
    border-radius: 2px;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    background: linear-gradient(to right, 
        #ff0000 0%, 
        #ffff00 17%, 
        #00ff00 33%, 
        #00ffff 50%, 
        #0000ff 67%, 
        #ff00ff 83%, 
        #ff0000 100%);
    font-size: 12px;
    text-align: center;
    line-height: 18px;
    color: #fff;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.ttb-color-custom:hover {
    border-color: #333;
}

/* Rahmen-Menü Styles */
.ttb-border-menu {
    position: absolute;
    top: 40px;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1071;
    width: 280px;
}

@media (prefers-color-scheme: dark) {
    .ttb-border-menu {
        background: #2a2a2a;
        border-color: #444;
        color: #fff;
    }
}

.ttb-border-menu-section {
    margin-bottom: 12px;
}

.ttb-border-menu-section:last-child {
    margin-bottom: 0;
}

.ttb-border-menu-section label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #666;
}

@media (prefers-color-scheme: dark) {
    .ttb-border-menu-section label {
        color: #ccc;
    }
}

.ttb-border-positions,
.ttb-border-styles {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ttb-border-pos,
.ttb-border-style {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.ttb-border-pos:hover,
.ttb-border-style:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.ttb-border-style.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.ttb-border-colors {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ttb-border-color-btn {
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    vertical-align: middle;
}

.ttb-border-color-btn:hover,
.ttb-border-color-btn.active {
    border-color: #0d6efd;
    transform: scale(1.1);
    box-shadow: 0 0 4px rgba(13, 110, 253, 0.5);
}

/* Icon-Style für Position-Buttons */
.ttb-border-pos {
    font-size: 16px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Stelle sicher dass Tabellen auch in der Ausgabe runde Ecken haben */
table {
    border-collapse: separate !important;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
}

table tr:first-child td:first-child,
table tr:first-child th:first-child {
    border-top-left-radius: 8px;
}

table tr:first-child td:last-child,
table tr:first-child th:last-child {
    border-top-right-radius: 8px;
}

table tr:last-child td:first-child,
table tr:last-child th:first-child {
    border-bottom-left-radius: 8px;
}

table tr:last-child td:last-child,
table tr:last-child th:last-child {
    border-bottom-right-radius: 8px;
}

/* Fix für Tabellen in Trumbowyg */
.trumbowyg-editor table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}

/* Runde Ecken für erste und letzte Zeile */
.trumbowyg-editor table tr:first-child td:first-child,
.trumbowyg-editor table tr:first-child th:first-child {
    border-top-left-radius: 8px;
}

.trumbowyg-editor table tr:first-child td:last-child,
.trumbowyg-editor table tr:first-child th:last-child {
    border-top-right-radius: 8px;
}

.trumbowyg-editor table tr:last-child td:first-child,
.trumbowyg-editor table tr:last-child th:first-child {
    border-bottom-left-radius: 8px;
}

.trumbowyg-editor table tr:last-child td:last-child,
.trumbowyg-editor table tr:last-child th:last-child {
    border-bottom-right-radius: 8px;
}

.trumbowyg-editor table td,
.trumbowyg-editor table th {
    min-width: 50px;
    min-height: 25px;
    padding: 5px;
    border: 1px solid #ddd;
    position: relative;
}

/* Hover-Effekt für Tabellenzellen */
.trumbowyg-editor table td:hover,
.trumbowyg-editor table th:hover {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* Fokus-Stil */
.trumbowyg-editor table td:focus,
.trumbowyg-editor table th:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    background-color: rgba(0, 123, 255, 0.05);
}

/* Verbundene Zellen Indikator */
.trumbowyg-editor table td[colspan],
.trumbowyg-editor table td[rowspan],
.trumbowyg-editor table th[colspan],
.trumbowyg-editor table th[rowspan] {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 123, 255, 0.03) 10px,
        rgba(0, 123, 255, 0.03) 20px
    );
}

/* Zellen-Auswahl beim Drag */
.trumbowyg-editor table td.ttb-selecting,
.trumbowyg-editor table th.ttb-selecting {
    background-color: rgba(33, 150, 243, 0.2) !important;
    outline: 2px solid #2196F3;
    outline-offset: -2px;
}