/* ============================================
   InputTemplate Form - Styles
   ============================================ */

/* Wrapper für alle Kategorien */
.it-categories-wrapper {
    margin-top: 20px;
}

/* Kategorie Container */
.it-category {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

/* Kategorie Header */
.it-category-header {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
}

.it-category-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Spalten-Header */
.it-columns-header {
    display: grid;
    grid-template-columns: 1fr 200px 1fr;
    gap: 16px;
    padding: 10px 20px;
    background: #f5f5f5;
    font-size: 11px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e0e0e0;
}

.it-col-amount, .it-col-remark {
    text-align: center;
}

/* FormGroup */
.it-formgroup {
    padding: 0 20px;
}

.it-formgroup-title {
    font-weight: 600;
    color: #333;
    padding: 14px 0 8px 0;
    font-size: 14px;
    border-bottom: 2px solid #ff9800;
    margin-bottom: 8px;
}

/* Material-Zeile */
.it-material-row {
    display: grid;
    grid-template-columns: 1fr 200px 1fr;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    align-items: center;
    transition: all 0.2s ease;
}

    .it-material-row:last-child {
        border-bottom: none;
    }

    .it-material-row.it-row-empty {
        opacity: 0.5;
    }

    .it-material-row:hover {
        opacity: 1 !important;
        background: rgba(255, 152, 0, 0.03);
    }

    .it-material-row.it-row-top {
        background: rgba(255, 255, 255, 0.8);
    }

    .it-material-row.it-row-single {
        background: rgba(40, 167, 69, 0.04);
    }

    .it-material-row.it-row-added {
        background: rgba(0, 123, 255, 0.04);
        border-left: 3px solid #007bff;
        padding-left: 17px;
        margin-left: -20px;
        margin-right: -20px;
        padding-right: 20px;
    }

    .it-material-row.it-row-freetext {
        background: rgba(108, 117, 125, 0.04);
        border-left: 3px solid #6c757d;
        padding-left: 17px;
        margin-left: -20px;
        margin-right: -20px;
        padding-right: 20px;
    }

    /* Dropdown-Zeile ohne Auswahl: komplett ausgegraut */
    .it-material-row.it-row-dropdown-empty {
        opacity: 0.6;
    }

/* Spalte: Name */
.it-col-name {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding-left: 4px;
}

.it-article-nr {
    font-weight: 700;
    color: #333;
    flex-shrink: 0;
    min-width: 55px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
}

.it-material-name {
    color: #333;
    /*white-space: nowrap;*/
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

/* Dropdown */
.it-dropdown {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .it-dropdown:hover {
        border-color: #bbb;
    }

    .it-dropdown:focus {
        border-color: #ff9800;
        outline: 0;
        box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.15);
    }

/* Spalte: Anzahl */
.it-col-amount {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.it-amount-control {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: visible;
    transition: all 0.2s ease;
}

    .it-amount-control:focus-within {
        border-color: #ff9800;
        box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.15);
    }

.it-btn-minus, .it-btn-plus {
    width: 40px;
    height: 40px;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 16px;
    margin-right: 0 !important;
}

.it-btn-minus {
    color: #dc3545;
    border-right: 1px solid #e0e0e0;
}

.it-btn-plus {
    color: #28a745;
    border-left: 1px solid #e0e0e0;
}

    .it-btn-minus:hover:not(.it-btn-disabled),
    .it-btn-plus:hover:not(.it-btn-disabled) {
        background: #e9ecef;
    }

    .it-btn-minus:active:not(.it-btn-disabled),
    .it-btn-plus:active:not(.it-btn-disabled) {
        background: #dee2e6;
        transform: scale(0.95);
    }

/* +/- Buttons DISABLED State (bei Dropdown ohne Auswahl) */
.it-btn-disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    color: #999 !important;
}

    .it-btn-disabled:hover {
        background: #f8f9fa !important;
    }

.it-amount-input {
    width: 60px;
    height: 40px;
    border: none;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    background: white;
    -moz-appearance: textfield;
    padding-left: 0 !important;
}

    .it-amount-input::-webkit-outer-spin-button,
    .it-amount-input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    .it-amount-input:focus {
        outline: none;
        background: #fffbe6;
    }

.it-unit {
    font-size: 13px;
    color: #666;
    min-width: 45px;
    white-space: nowrap;
    font-weight: 500;
}

/* Container fuer dynamisch hinzugefuegte Zeilen am Ende der Kategorie */
.it-category-added-rows {
    padding: 0 20px;
}

.it-category-added-rows-existing {
    padding: 0 20px;
}

    .it-category-added-rows .it-material-row,
    .it-category-added-rows-existing .it-material-row {
        margin-left: 0;
        margin-right: 0;
        padding-left: 20px;
        padding-right: 20px;
    }

/* Spalte: Bemerkung */
.it-col-remark {
    display: flex;
    align-items: center;
}

.it-remark-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

    .it-remark-input::placeholder {
        color: #aaa;
    }

    .it-remark-input:hover {
        border-color: #bbb;
    }

    .it-remark-input:focus {
        border-color: #ff9800;
        outline: 0;
        box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.15);
    }

/* Freitext-Input */
.it-freetext-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

/* Action Buttons */
.it-category-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.it-action-btn {
    padding: 10px 18px;
    border: 2px solid;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .it-action-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

.it-action-add {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

    .it-action-add:hover {
        background: #4caf50;
        color: white;
    }

.it-action-master {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1565c0;
}

    .it-action-master:hover {
        background: #2196f3;
        color: white;
    }

.it-action-freetext {
    background: #fff8e1;
    border-color: #ffc107;
    color: #f57f17;
}

    .it-action-freetext:hover {
        background: #ffc107;
        color: #212529;
    }

/* Entfernen-Button */
.it-remove-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: #ffebee;
    color: #c62828;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 10px;
    transition: all 0.2s ease;
}

    .it-remove-btn:hover {
        background: #ef5350;
        color: white;
        transform: scale(1.05);
    }

/* DB-Delete Button (als Link styled) */
.it-remove-btn-db {
    text-decoration: none;
}

    .it-remove-btn-db:hover {
        background: #ef5350;
        color: white;
        transform: scale(1.05);
        text-decoration: none;
    }

/* Copy/Übernehmen-Button */
.it-btn-copy {
    width: 26px;
    height: 26px;
    border: 1.5px solid #4caf50;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 6px;
    transition: all 0.15s ease;
    font-size: 12px;
    vertical-align: middle;
    padding: 0;
    position: relative;
    z-index: 1;
}

    .it-btn-copy:hover {
        background: #4caf50;
        border-color: #4caf50;
        color: white;
        transform: scale(1.05);
    }

    .it-btn-copy.it-copy-pulse {
        animation: copyPulse 2s ease-in-out infinite;
    }

@keyframes copyPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(76, 175, 80, 0);
    }
}

/* Standard Material Row Copy Button */
.it-btn-copy-std {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1.5px solid #4caf50;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    vertical-align: middle;
    transition: all 0.15s ease;
    position: relative;
    z-index: 1;
}

    .it-btn-copy-std:hover {
        background: #4caf50;
        border-color: #4caf50;
        color: white;
        transform: scale(1.05);
    }

    .it-btn-copy-std.it-copy-pulse {
        animation: copyPulse 2s ease-in-out infinite;
    }

/* Copy-Value Popup */
.it-copy-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 20px;
    z-index: 10001;
    min-width: 280px;
    max-width: 90vw;
}

.it-copy-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
}

.it-copy-popup-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .it-copy-popup-title i {
        color: #4caf50;
    }

.it-copy-popup-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.it-copy-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .it-copy-option:hover {
        border-color: #4caf50;
        background: #f1f8e9;
    }

.it-copy-option-value {
    font-size: 18px;
    font-weight: 700;
    color: #2e7d32;
    margin-right: 8px;
}

.it-copy-option-unit {
    font-size: 14px;
    color: #666;
    margin-right: auto;
}

.it-copy-option-source {
    font-size: 12px;
    color: #999;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.it-copy-popup-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.it-copy-popup-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.it-copy-popup-btn-cancel {
    background: #f5f5f5;
    color: #666;
}

    .it-copy-popup-btn-cancel:hover {
        background: #e0e0e0;
    }

.it-copy-popup-btn-confirm {
    background: #4caf50;
    color: white;
}

    .it-copy-popup-btn-confirm:hover {
        background: #43a047;
    }

/* Row mit Haekchen wenn andere Zeile gleichen Typs ausgefuellt */
.it-material-row.it-has-sibling-filled::before {
    content: '\f00c';
    font-family: 'FontAwesome';
    color: #28a745;
    margin-right: 8px;
    opacity: 0.5;
}

/* Bemerkung Toggle Button */
.it-remark-toggle {
    display: none; /* Nur auf Mobile sichtbar */
    width: 36px;
    height: 36px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    flex-shrink: 0;
}

    .it-remark-toggle:hover {
        background: #e9ecef;
    }

    .it-remark-toggle.active {
        background: #007bff;
        color: white;
        border-color: #007bff;
    }

/* ============================================
   Globale Material-Buttons am Ende
   ============================================ */

.it-global-actions {
    background: #fff;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
}

.it-global-actions-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 12px;
    font-size: 14px;
}

.it-global-actions-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Standard costscontainer innerhalb Template */
.it-global-actions #costscontainer {
    margin-bottom: 16px;
}

    .it-global-actions #costscontainer:empty {
        display: none;
    }

/* ============================================
   Responsive Styles
   ============================================ */

@media (max-width: 768px) {
    .it-columns-header {
        display: none;
    }

    .it-material-row {
        grid-template-columns: 1fr auto;
        gap: 8px;
        padding: 12px 0;
    }

    .it-col-name {
        grid-column: 1 / -1;
        order: 1;
    }

    .it-col-amount {
        order: 2;
        justify-content: flex-start;
        flex: 1;
    }

    .it-col-remark {
        order: 3;
        flex-direction: column;
        align-items: flex-start;
    }

    /* Toggle Button auf Mobile anzeigen */
    .it-remark-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Bemerkung-Input versteckt auf Mobile */
    .it-remark-input.it-remark-hidden {
        display: none;
    }

    .it-remark-input:not(.it-remark-hidden) {
        width: 100%;
        margin-top: 8px;
    }

    /* Groessere Touch-Targets */
    .it-btn-minus, .it-btn-plus {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .it-amount-input {
        width: 60px;
        height: 44px;
        font-size: 16px;
    }

    .it-amount-control {
        border-radius: 6px;
    }

    .it-category-actions {
        flex-direction: column;
    }

    .it-action-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Dropdown groesser */
    .it-dropdown {
        padding: 12px;
        font-size: 16px;
    }

    /* Unit besser sichtbar */
    .it-unit {
        font-size: 14px;
        font-weight: 500;
    }
}

/* Desktop: Bemerkung immer sichtbar, kein Toggle */
@media (min-width: 769px) {
    .it-remark-toggle {
        display: none !important;
    }

    .it-remark-input.it-remark-hidden {
        display: block !important;
    }
}

/* ============================================
   Tooltip fuer "Bitte zuerst Material waehlen"
   ============================================ */
.it-select-tooltip {
    position: fixed;
    background-color: #333;
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

    .it-select-tooltip::after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        border-width: 8px 8px 0 8px;
        border-style: solid;
        border-color: #333 transparent transparent transparent;
    }

    .it-select-tooltip.it-tooltip-visible {
        opacity: 1;
    }

/* ============================================
   Top-Materials Container
   ============================================ */
.it-top-materials {
    border-bottom: 1px dashed #ddd;
    margin-bottom: 8px;
    padding-bottom: 8px;
}

/* ============================================
   Zusammenfassung vor Speichern
   ============================================ */
.it-summary {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 24px;
    margin-bottom: 16px;
}

.it-summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ff9800;
}

    .it-summary-header i {
        color: #ff9800;
        font-size: 18px;
    }

.it-summary-title {
    font-weight: 700;
    font-size: 15px;
    color: #333;
}

.it-summary-count {
    background: #ff9800;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: auto;
}

.it-summary-empty {
    color: #6c757d;
    font-style: italic;
    font-size: 13px;
    padding: 8px 0;
}

.it-summary-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.it-summary-category {
    background: white;
    border-radius: 8px;
    padding: 10px 14px;
    border-left: 3px solid #ff9800;
}

.it-summary-category-title {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    margin-bottom: 6px;
}

.it-summary-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.it-summary-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
}

.it-summary-item-amount {
    font-weight: 700;
}

.it-summary-item-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
   /* white-space: nowrap;*/
}

.it-summary-item-unit {
    color: #388e3c;
    font-size: 11px;
}

/* Freitext/OtherCost Items */
.it-summary-item.it-summary-item-freetext {
    background: #fff3e0;
    color: #e65100;
}

    .it-summary-item.it-summary-item-freetext .it-summary-item-unit {
        color: #f57c00;
    }

/* Extra-Materialien */
.it-summary-item.it-summary-item-extra {
    background: #e3f2fd;
    color: #1565c0;
}

    .it-summary-item.it-summary-item-extra .it-summary-item-unit {
        color: #1976d2;
    }

/* Responsive */
@media (max-width: 768px) {
    .it-summary {
        padding: 12px 14px;
    }

    .it-summary-item {
        font-size: 11px;
        padding: 3px 8px;
    }

    .it-summary-item-name {
        max-width: 100px;
    }
}
