:root {
    --app-cm-green: #007a5e;
    --app-cm-red: #ce1126;
    --app-cm-yellow: #fcd116;
    --app-green-900: #14532d;
    --app-green-800: #166534;
    --app-green-600: #16a34a;
    --app-modal-surface: rgba(255, 255, 255, 0.96);
    --app-modal-border: rgba(15, 23, 42, 0.12);
    --app-modal-radius: 24px;
    --app-modal-shadow: 0 30px 90px rgba(2, 6, 23, 0.35);
}

/* ==========================================================================
   Shared modal theme (projects + table builder)
   ========================================================================== */
.app-modal-content {
    border: none;
    border-radius: var(--app-modal-radius);
    overflow: hidden;
    background: var(--app-modal-surface);
    box-shadow: var(--app-modal-shadow);
}

.modal-fullscreen .app-modal-content {
    border-radius: 0;
    box-shadow: none;
}

.app-modal-header {
    position: relative;
    border: none;
    padding: 1.05rem 1.25rem;
    background: linear-gradient(135deg, var(--app-green-900) 0%, var(--app-green-800) 52%, var(--app-green-600) 100%);
    color: rgba(255, 255, 255, 0.95);
}

.app-modal-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: linear-gradient(
        90deg,
        var(--app-cm-green) 0%,
        var(--app-cm-green) 33%,
        var(--app-cm-red) 33%,
        var(--app-cm-red) 66%,
        var(--app-cm-yellow) 66%,
        var(--app-cm-yellow) 100%
    );
    opacity: 0.95;
}

.app-modal-title {
    font-weight: 800;
    letter-spacing: -0.2px;
    margin: 0;
}

.app-modal-body {
    background:
        radial-gradient(circle at 15% 0%, rgba(34, 197, 94, 0.1), transparent 42%),
        radial-gradient(circle at 85% 0%, rgba(252, 209, 22, 0.08), transparent 45%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.92) 100%);
}

.app-modal-footer {
    border: none;
    background: rgba(20, 83, 45, 0.04);
}

.app-modal-header .nav-tabs {
    gap: 0.5rem;
    margin-top: 0.75rem;
    border-bottom: none;
}

.app-modal-header .nav-tabs .nav-link {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.88);
    background: rgba(255, 255, 255, 0.12);
    font-weight: 700;
    padding: 0.45rem 0.85rem;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.app-modal-header .nav-tabs .nav-link:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.35);
}

.app-modal-header .nav-tabs .nav-link.active {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(255, 255, 255, 0.7);
    color: var(--app-green-900);
    box-shadow: 0 12px 25px rgba(2, 6, 23, 0.08);
}

.table-wrapper {
    margin-top: 20px;
    overflow-x: auto; /* Prevent table overflow */
}

/* Table-builder grid styles (scoped).
   Note: avoid styling all tables globally because the project/context UI also uses tables. */
#dynamicTable {
    min-width: 100%; /* Ensure the table fits within the container without overlapping */
    border-collapse: collapse;
}
#dynamicTable td,
#dynamicTable th {
    border: 1px solid #4CAF50;
    padding: 10px;
    text-align: center;
    position: relative;
}
#dynamicTable td input {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

/* When vertically merged (rowspan > 1), center the control inside the taller cell.
   The control MUST stay in the normal flow: an absolutely positioned child
   contributes no intrinsic width, so under `table-layout: auto` the column
   collapses to its padding (~30px) and the value is clipped to nothing —
   which is exactly what happened to a merged row-dimension cell. Vertical
   centering is a cell-level concern, so it belongs on the cell. */
#dynamicTable td[rowspan]:not([rowspan="1"]) {
    vertical-align: middle;
}
#dynamicTable td.selected {
    background-color: #d4edda; /* Highlight selected cells */
}
#dynamicTable td input:focus {
    background-color: #ffffcc; /* Highlight focused input */
}
#dynamicTable td {
    cursor: pointer;
}

/* Preview/export modal table (table-builder only). */
#previewModal #htmlTableContainer table {
    width: 100%;
    border-collapse: collapse;
}
#previewModal #htmlTableContainer td,
#previewModal #htmlTableContainer th {
    border: 1px solid #4CAF50;
    padding: 10px;
    text-align: center;
    vertical-align: middle;
}

/* Rotated text support (used by style-config orientation controls). */
.yb-rotated-text {
    position: relative;
    overflow: visible;
}

.yb-rotated-text .yb-cell-text {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(var(--yb-text-rotation));
    transform-origin: center center;
    white-space: normal;
    line-height: 1.1;
    width: calc(100% - 8px);
    max-width: none;
    text-overflow: clip;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: center;
}

.yb-rotated-text.yb-text-vertical .yb-cell-text {
    transform-origin: center center;
}

.yb-rotated-text.yb-text-diagonal {
    vertical-align: middle !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    height: 92px;
    min-height: 92px;
}

.yb-rotated-text.yb-text-diagonal .yb-cell-text {
    transform-origin: center center;
    line-height: 1;
}
.large-button {
    font-size: 16px;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    margin-right: 10px;
}
.large-button:hover {
    background-color: #45a049;
}
.dropdown-menu {
    display: none;
    position: absolute;
    z-index: 1000;
    background-color: white;
    border: 1px solid #ccc;
    padding: 10px;
}
.dropdown-menu.show {
    display: block;
}
.dropdown-menu a {
    display: block;
    padding: 5px;
    color: black;
    text-decoration: none;
}
.dropdown-menu a:hover {
    background-color: #f0f0f0;
}
.submenu {
    display: none;
    position: absolute;
    top: 0;
    left: 150px;
    background-color: white;
    border: 1px solid #ccc;
    padding: 10px;
    z-index: 1001;
}
.dropdown-menu > li:hover .submenu {
    display: block;
}

#sidebar {
    height: 100vh;
    width: 250px;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #343a40;
    padding-top: 20px;
    transition: all 0.3s;
}
#sidebar .nav-link {
    color: #ffffff;
}
#sidebar .nav-link:hover {
    color: #adb5bd;
}

#rightMenu {
    height: 100vh;
    width: 250px;
    position: fixed;
    top: 0;
    right: 0;
    padding-top: 20px;
    background-color: #f8f9fa;
    transition: all 0.3s;
    display: none;
}

#closeRightMenu {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 20px;
    color: #000;
}

@media (max-width: 768px) {
    #sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    #rightMenu {
        width: 100%;
        height: auto;
        position: relative;
    }
    .container-fluid {
        flex-direction: column;
    }
    .large-button {
        width: 100%;
        font-size: 14px;
        padding: 8px;
        margin-bottom: 10px;
    }
    td input {
        padding: 8px;
        font-size: 14px;
    }
    #dynamicTable {
        width: 100%;
    }
}
