/* ==========================================================================
   1. FRAMEWORK IMPORTS (Pfade aus deinem Original beibehalten)
   ========================================================================== */
@import "bootstrap.min-RB0qvW3.css";
@import "../vendor/bootstrap-icons/font/bootstrap-icons.min-5BD67CJ.css";
@import "../vendor/tom-select/dist/css/tom-select.default.min-5Ubr_SJ.css";

/* ==========================================================================
   2. GLOBAL APPLICATION LAYOUT & FONTS
   ========================================================================== */
body {
    background-color: #f4f6f8; /* Mattes, professionelles Hintergrund-Grau */
    color: #2d3748;            /* Weicheres Anthrazit statt hartem Tiefschwarz */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* PREMIUM CONFIG: Verhindert, dass Zeiterfassungen & Summen beim Ticken 
       oder Editieren horizontal wackeln, da alle Ziffern exakt gleich breit werden */
    font-variant-numeric: tabular-nums; 
}

/* ==========================================================================
   3. ANIMATIONS & MICRO-INTERACTIONS
   ========================================================================== */

/* Dezent edler Hover-Effekt für die Inline-Editier-Links */
.hover-bg-light {
    transition: background-color 0.15s ease, color 0.15s ease;
}
.hover-bg-light:hover {
    background-color: #e9ecef !important;
    color: #0d6efd !important; /* Färbt den Text beim Drüberfahren leicht blau */
}

/* Pulsierender Effekt für den "läuft..."-Status (Live-Tracker) */
@keyframes pulse-subtle {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.75; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}
.animate-pulse {
    animation: pulse-subtle 2s infinite ease-in-out;
}

/* Weiche Einblend-Animation für das User-Dropdown in der Kopfzeile */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate.fade-in {
    animation: fadeIn 0.15s ease-out forwards;
}

/* ==========================================================================
   4. TURBO FRAME TRANSITIONS
   ========================================================================== */
turbo-stream[action="remove"] {
    /* Zeilen-Klasse vor dem Löschen */
}

.removing {
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    transform: translateX(20px);
}

/* ==========================================================================
   5. TOMSELECT BOOTSTRAP 5 HARMONIZATION (Konsolidiert & Bereinigt)
   ========================================================================== */
.ts-wrapper {
    position: relative !important;
    width: 100% !important; /* Nimmt die volle Breite der Bootstrap-Spalte ein */
}

.ts-wrapper.form-select, 
.ts-wrapper.form-control {
    border: none !important;
    padding: 0 !important;
    height: auto !important;
    background: none !important;
    box-shadow: none !important;
}

.ts-wrapper.form-select.input-active {
    color: var(--bs-body-color) !important;
    background-color: var(--bs-body-bg) !important;
    border-color: #86b7fe !important;
    outline: 0;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .25) !important;
}

/* Das sichtbare Auswahlfeld (Control) */
.ts-control {
    border: 1px solid #dee2e6 !important; /* Bootstrap-Grau */
    border-radius: 0.25rem !important;
    padding: .25rem .5rem !important;    /* sm-Größe */
    background-color: #fff !important;
    display: flex !important;
    align-items: center !important;
    min-height: calc(1.5em + .5rem + 2px) !important;
}

/* Das native Input-Feld zähmen */
.ts-wrapper .ts-control input {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    display: inline-block !important;
    width: 2px !important;
}

/* Das Suchfeld innerhalb des Dropdowns */
.ts-dropdown .dropdown-input-wrap {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 5px;
}

.ts-dropdown .dropdown-input {
    width: 100% !important;
    box-sizing: border-box !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.2rem !important;
    padding: .25rem !important;
    font-size: 0.875rem !important;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
}

.ts-dropdown .dropdown-input:focus {
    border-color: #0d6efd !important;
    outline: 0 !important;
}

/* Das schwebende Dropdown-Menü selbst */
.ts-wrapper .ts-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important; 
    margin: 2px 0 0 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    z-index: 1050 !important;
}

/* Optionen im Dropdown */
.ts-dropdown .option {
    padding: 6px !important;
    cursor: pointer;
}

.ts-dropdown .option.active {
    background-color: #0d6efd !important;
    color: white !important;
}

.ts-hidden-accessible {
    display: none !important;
}

select[data-controller="select"] {
    display: none !important;
}

/* Statischer Dropdown-Pfeil (falls aktiviert) */
.ts-wrapper.single .ts-control {
    padding-right: 2rem !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
}

/* ==========================================================================
   6. MODERN RESPONSIVE TABLE CONFIGURATION (Konsolidiert)
   ========================================================================== */

.modern-responsive-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
}

/* --- Globaler Standard für die Summenzeile (Desktop-Look) --- */
.table-info-clean {
    background-color: #f8f9fa !important; 
    color: #2d3748 !important;
}
.table-info-clean td {
    background-color: #f8f9fa !important;
    border-top: 2px solid #dee2e6 !important;
}

/* --------------------------------------------------------------------------
   DESKTOP INTERACTIONS & LAYOUT (Ab 768px Viewport-Breite)
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
    .col-date     { width: 12%; padding-left: 1.5rem !important; }
    .col-start    { width: 8%; }
    .col-end      { width: 8%; }
    .col-duration { width: 10%; padding-right: 1rem !important; font-family: var(--bs-font-monospace); }
    .col-project  { width: 22%; }
    .col-desc     { width: auto; }
    .col-actions  { width: 12%; padding-right: 1.5rem !important; }
    
    .modern-responsive-table td {
        padding: 0.75rem 0.5rem;
        vertical-align: middle;
        border-bottom: 1px solid #dee2e6;
    }

    /* Zeilen-Hervorhebung beim Hovern */
    .modern-responsive-table tbody tr.activity-row {
        transition: background-color 0.15s ease-in-out;
    }
    .modern-responsive-table tbody tr.activity-row:hover {
        background-color: rgba(0, 0, 0, 0.04) !important;
    }

    /* Aktions-Buttons (Kopieren/Löschen) per Default verstecken */
    .modern-responsive-table .col-actions .btn {
        opacity: 0;
        transition: opacity 0.15s ease-in-out;
    }
    /* ...und bei Zeilen-Hover einblenden */
    .modern-responsive-table tr.activity-row:hover .col-actions .btn {
        opacity: 1;
    }

    /* 3. Bearbeitungsstifte im Desktop-Umfeld standardmäßig unsichtbar machen */
    .modern-responsive-table .inline-edit-pencil {
        font-size: 0.7rem;
        color: #6c757d;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.15s ease-in-out, visibility 0.15s ease-in-out;
    }
    
    /* Aktiviert den Hover-Effekt auf der Zelle */
    .modern-responsive-table td[class*="col-"]:hover .inline-edit-pencil {
        opacity: 0.5;
        visibility: visible;
    }

    /* NEU: Verhindert, dass das Feld beim Wechsel in den Edit-Modus einfriert */
    .modern-responsive-table td turbo-frame {
        display: block;
        width: 100%;
    }

    /* Styling für das aktive Input-Feld in der Tabelle */
    .inline-edit-input {
        width: 100%;
        padding: 0.25rem 0.5rem;
        font-size: 0.9rem;
        border: 1px solid #0d6efd !important; /* Blauer Rahmen beim Editieren */
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15) !important;
    }
}

/* --------------------------------------------------------------------------
   MOBILE CARD TRANSFORMATION (Unterhalb von 768px Viewport-Breite)
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    
    /* Verstecke klassischen Tabellenkopf */
    .modern-responsive-table thead {
        display: none;
    }

    /* Elemente untereinander anordnen */
    .modern-responsive-table, 
    .modern-responsive-table tbody, 
    .modern-responsive-table tfoot {
        display: block;
        width: 100%;
    }

    /* Zeile wird zur freistehenden Karte */
    .modern-responsive-table .activity-row {
        display: flex;
        flex-direction: column;
        background-color: #ffffff;
        border-radius: 12px;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    /* Zelle wird zur Zeile innerhalb der Karte */
    .modern-responsive-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
        width: 100% !important;
    }

    /* Dynamische Labels injizieren */
    .modern-responsive-table td[data-label]::before {
        content: attr(data-label);
        font-size: 0.75rem;
        text-transform: uppercase; /* FIX: Korrigierte CSS-Syntax */
        font-weight: 700;
        color: #6c757d;
        letter-spacing: 0.5px;
    }

    /* Auf Touch-Geräten müssen Interaktionselemente dauerhaft sichtbar sein (Kein Hover!) */
    .modern-responsive-table .col-actions .btn {
        opacity: 1 !important;
        padding: 0.4rem 0.8rem !important;
    }
    
    /* Mobil-Korrektur: Stifte auf Handys permanent dezent anzeigen (kein Hover möglich) */
    .modern-responsive-table .inline-edit-pencil {
        font-size: 0.7rem;
        color: #6c757d;
        opacity: 0.4;
        visibility: visible;
    }

    /* Spezifische Mobil-Anpassungen für Felder */
    .col-date {
        border-bottom: 1px solid #f1f3f5 !important;
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.25rem;
    }
    .col-date a { font-weight: 700; color: #0d6efd !important; }

    .col-duration .duration-value {
        background-color: #212529;
        color: #ffffff !important;
        padding: 0.25rem 0.6rem;
        border-radius: 6px;
        font-size: 0.9rem;
    }

    .project-info-wrapper {
        display: flex;
        flex-direction: column;
        text-align: right;
    }

    .col-desc {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    .col-desc::before { margin-bottom: 0.25rem; }
    .col-desc turbo-frame { width: 100%; }
    .col-desc a, .col-desc input {
        width: 100%;
        padding: 0.5rem !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 6px;
        background-color: #f8f9fa;
    }

    .col-actions {
        justify-content: flex-end !important;
        border-top: 1px solid #f1f3f5 !important;
        margin-top: 0.5rem;
        padding-top: 0.75rem !important;
    }

    /* Edle, kontrastreiche Mobil-Gesamtsummen-Karte */
    .table-info-clean {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background-color: #212529 !important;
        color: #ffffff !important;
        border-radius: 12px;
        padding: 1rem;
        margin-top: 1rem;
    }
    .table-info-clean td {
        display: inline-block;
        width: auto !important;
        padding: 0 !important;
        background: transparent !important;
        color: white !important;
        border: none !important;
    }
    .table-info-clean .total-label { font-weight: normal; font-size: 0.9rem; }
    .table-info-clean .total-value { font-size: 1.3rem; font-weight: 700; }
}

/* ==========================================================================
   9. CUSTOMER MANAGEMENT EXTENSIONS
   ========================================================================== */

/* Spaltenbreiten & Paddings im Desktop-Layout (Ab 768px) */
@media (min-width: 768px) {
    .customer-col-status  { width: 15%; padding-left: 1.5rem !important; }
    .customer-col-name    { width: 50%; }
    .customer-col-rate    { width: 20%; padding-right: 1.5rem !important; }
    .customer-col-actions { width: 15%; padding-right: 1.5rem !important; }

    /* Zeilen-Hover-Effekt für die Aktionsbuttons der Kundenverwaltung */
    .modern-responsive-table tr.customer-row-item .customer-col-actions .btn {
        opacity: 0;
        transition: opacity 0.15s ease-in-out;
    }
    .modern-responsive-table tr.customer-row-item:hover .customer-col-actions .btn {
        opacity: 1;
    }
}

/* Stilistische Anpassung für archivierte Kunden */
.customer-archived {
    background-color: #fcfdfd !important;
    opacity: 0.75;
}

/* Premium, flache Badges statt den klobigen Standard-Bootstrap-Kugeln */
.badge-active-clean {
    background-color: #e6f4ea !important;
    color: #137333 !important;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
}

.badge-archived-clean {
    background-color: #f1f3f4 !important;
    color: #5f6368 !important;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
}

/* Monospace-Schriftart für fluchtende Zahlenwerte */
.fw-mono {
    font-family: var(--bs-font-monospace);
}

/* Mobile Korrekturen für die Kunden-Ansicht */
@media (max-width: 767.98px) {
    .customer-col-rate .rate-value {
        background-color: #f8f9fa;
        color: #212529 !important;
        border: 1px solid #dee2e6;
        padding: 0.25rem 0.6rem;
        border-radius: 6px;
        font-size: 0.9rem;
    }
    
    /* Knöpfe auf Smartphones bei Kunden immer anzeigen */
    .modern-responsive-table tr.customer-row-item .customer-col-actions .btn {
        opacity: 1 !important;
    }
}