/* Ampel Cards Frontend Styles */

.ampel-cards-container {
    max-width: 1200px;
    margin: 0 auto;
}

.ampel-cards-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ampel-cards-row {
    display: flex;
    align-items: stretch;
    margin-bottom: 25px;
    gap: 15px;
    min-height: auto; /* Allow custom height override */
}

/* Ensure traffic light and cards have same height */
.ampel-cards-row .traffic-light,
.ampel-cards-row .traffic-image,
.ampel-cards-row .ampel-card {
    align-self: stretch;
}

.ampel-cards-row-cards {
    display: flex;
    gap: 15px;
    flex: 1;
    width: 100%; /* Ensure full width usage */
    box-sizing: border-box;
}

.ampel-cards-list li {
    display: flex;
    align-items: stretch;
}

.ampel-cards-list li img {
    border-radius: 8px;
    /* box-shadow: 0 2px 4px rgba(0,0,0,0.1); */
    transition: transform 0.2s ease;
}

.ampel-cards-list li img:hover {
    transform: scale(1.05);
}

/* Traffic Light Image Auto-sizing - Lower specificity to allow inline styles */
.ampel-cards-row img.traffic-image {
    border-radius: 8px;
    /* box-shadow: 0 2px 8px rgba(0,0,0,0.2); */
    align-self: stretch !important;
    flex-shrink: 0 !important;
}

/* Remove any width restrictions and let inline styles control width completely */
img.traffic-image[style*="width"] {
    /* Inline styles will control width completely */
}

/* Traffic image height override - ALLOW INLINE STYLES TO SET HEIGHT */
.ampel-cards-row img.traffic-image[style*="height"] {
    max-height: none !important;
    min-height: auto !important;
}

.traffic-light {
    width: 60px;
    min-height: 180px;
    background: #333;
    border-radius: 10px;
    margin: 0 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    position: relative;
}

/* Removed top dot - traffic light is now a simple rectangle */

.traffic-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #555;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    position: relative;
}

.traffic-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: inherit;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.traffic-dot.red {
    background: #dc3545;
}

.traffic-dot.yellow {
    background: #ffc107;
}

.traffic-dot.green {
    background: #28a745;
}

.traffic-dot.off {
    background: #6c757d;
    box-shadow: none;
}

.ampel-card {
    display: flex;
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: #212529;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex: 1;
    min-height: 130px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
    width: 100%; /* Ensure full width usage */
    box-sizing: border-box;
}

.ampel-card strong {
    font-size: 16px;
    margin-bottom: 8px;
    display: block;
    font-family: Arial, sans-serif; /* Default fallback */
    /* Allow inline styles to override */
}

.ampel-card span {
    font-size: 14px;
    display: block;
    margin-top: 0; /* Reset to 0 - gap will be controlled by PHP inline styles */
    font-family: Arial, sans-serif; /* Default fallback */
    /* Allow inline styles to override */
}

/* Default traffic light colors - only apply if no custom card color is set */
.ampel-cards-row[data-status="green"] .ampel-card:not([style*="background-color"]) {
    background: linear-gradient(135deg, #81c784, #66bb6a) !important;
    color: #fff !important;
    font-weight: bold !important;
}

.ampel-cards-row[data-status="yellow"] .ampel-card:not([style*="background-color"]) {
    background: linear-gradient(135deg, #ffb74d, #ffa726) !important;
    color: #333 !important;
    font-weight: bold !important;
}

.ampel-cards-row[data-status="red"] .ampel-card:not([style*="background-color"]) {
    background: linear-gradient(135deg, #d32f2f, #c62828) !important;
    color: #fff !important;
    font-weight: bold !important;
}

/* Card background color override - SIMPLIFIED AND FIXED */
.ampel-cards-row .ampel-card[style*="background-color:"],
.ampel-cards-row .ampel-card[style*="!important"] {
    background-image: none !important;
}

.ampel-cards-row[data-status="green"] .ampel-card[style*="background-color:"],
.ampel-cards-row[data-status="green"] .ampel-card[style*="!important"] {
    background-image: none !important;
}

.ampel-cards-row[data-status="yellow"] .ampel-card[style*="background-color:"],
.ampel-cards-row[data-status="yellow"] .ampel-card[style*="!important"] {
    background-image: none !important;
}

.ampel-cards-row[data-status="red"] .ampel-card[style*="background-color:"],
.ampel-cards-row[data-status="red"] .ampel-card[style*="!important"] {
    background-image: none !important;
}

.ampel-cards-list li a {
    display: block;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #212529;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex: 1;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ampel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    text-decoration: none;
}

.ampel-cards-row[data-status="green"] .ampel-card:not([style*="background-color"]):hover {
    background: linear-gradient(135deg, #66bb6a, #4caf50) !important;
}

.ampel-cards-row[data-status="yellow"] .ampel-card:not([style*="background-color"]):hover {
    background: linear-gradient(135deg, #ffa726, #ff9800) !important;
}

.ampel-cards-row[data-status="red"] .ampel-card:not([style*="background-color"]):hover {
    background: linear-gradient(135deg, #ef5350, #f44336) !important;
}

/* Hover overrides for cards with custom background colors */
.ampel-cards-row .ampel-card[style*="background-color:"]:hover,
.ampel-cards-row .ampel-card[style*="!important"]:hover {
    background-image: none !important;
}

.ampel-cards-row[data-status="green"] .ampel-card[style*="background-color:"]:hover,
.ampel-cards-row[data-status="green"] .ampel-card[style*="!important"]:hover {
    background-image: none !important;
}

.ampel-cards-row[data-status="yellow"] .ampel-card[style*="background-color:"]:hover,
.ampel-cards-row[data-status="yellow"] .ampel-card[style*="!important"]:hover {
    background-image: none !important;
}

.ampel-cards-row[data-status="red"] .ampel-card[style*="background-color:"]:hover,
.ampel-cards-row[data-status="red"] .ampel-card[style*="!important"]:hover {
    background-image: none !important;
}

.ampel-cards-list li a:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    text-decoration: none;
}

.ampel-cards-list li a strong {
    display: block;
    margin-bottom: 8px;
    line-height: 1.4;
}

.ampel-cards-list li a span {
    display: block;
    line-height: 1.5;
}

/* Desktop: Equal total span for all rows regardless of card count */
@media screen and (min-width: 770px) {
    /* All rows take full available width consistently */
    .ampel-cards-row {
        width: 100%;
        display: flex;
        align-items: stretch;
        gap: 15px;
        margin-bottom: 25px;
    }
    
    /* Traffic light always takes fixed space */
    .ampel-cards-row .traffic-light,
    .ampel-cards-row .traffic-image {
        flex: 0 0 60px; /* Fixed width, no grow/shrink */
    }
    
    /* Cards container takes remaining space after traffic light */
    .ampel-cards-row .first-card {
        flex: 1; /* Default: take all remaining space for single card */
    }
    
    .ampel-cards-row .ampel-cards-row-cards {
        flex: 1; /* Take all remaining space for multiple cards container */
    }
    
    /* For rows with exactly 3 cards - use same flex approach as other rows */
    .ampel-cards-row.three-cards .first-card {
        flex: 1; /* Same as other rows - equal share of available space */
    }
    
    .ampel-cards-row.three-cards .ampel-cards-row-cards {
        flex: 2; /* Takes 2x space to accommodate 2 cards with equal distribution */
        display: flex;
        gap: 15px;
    }
    
    .ampel-cards-row.three-cards .ampel-cards-row-cards .ampel-card {
        flex: 1; /* Each of the 2 cards gets equal space in their container */
    }
    
    /* For rows with 2 cards total */
    .ampel-cards-row:not(.three-cards) .first-card {
        flex: 1; /* First card takes half of available space */
    }
    
    .ampel-cards-row:not(.three-cards) .ampel-cards-row-cards {
        flex: 1; /* Remaining cards take other half */
    }
    
    .ampel-cards-row:not(.three-cards) .ampel-cards-row-cards .ampel-card {
        flex: 1; /* Equal distribution within container */
    }
}

/* Responsive Design */
@media screen and (max-width: 769px) {
    .ampel-cards-container {
        max-width: 100%;
    }
    
    .ampel-cards-row {
        display: flex;
        flex-direction: row; /* Traffic light + first card horizontal */
        align-items: stretch;
        gap: 10px;
        margin-bottom: 25px;
        flex-wrap: wrap; /* Allow wrapping for remaining cards */
    }
    
    /* Remaining cards: full width below */
    .ampel-cards-row-cards {
        flex: 1 1 100%; /* Take full width and wrap to new line */
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 10px;
    }
    
    .traffic-light {
        margin: 0;
        width: 60px;
        padding: 8px;
        flex-shrink: 0;
        /* Keep vertical layout for better visual */
        flex-direction: column;
        justify-content: space-around;
        /* Match first card height exactly */
        align-self: stretch;
        height: auto;
        min-height: 100px;
    }
    
    .traffic-light .traffic-dot {
        width: 32px;
        height: 32px;
        margin: 2px 0;
    }
    
    .traffic-light .traffic-dot::before {
        width: 24px;
        height: 24px;
    }
    
    .ampel-cards-row img.traffic-image {
        flex-shrink: 0 !important;
        align-self: stretch !important;
        height: auto !important;
        object-fit: fill !important;
        /* Let inline styles control width on mobile too */
    }
    
    /* First card - shares row with traffic light */
    .ampel-card.first-card {
        flex: 1;
        min-height: 100px;
        padding: 15px;
        box-sizing: border-box;
        margin-bottom: 0;
        /* Ensure consistent height with traffic light */
        align-self: stretch;
    }
    
    /* Other cards - full width in .ampel-cards-row-cards */
    .ampel-cards-row-cards .ampel-card {
        width: 100%;
        min-height: 100px;
        padding: 15px;
        box-sizing: border-box;
        margin-bottom: 0;
    }
    
    .ampel-card strong {
        font-size: 15px;
        line-height: 1.3;
    }
    
    .ampel-card span {
        font-size: 13px;
        line-height: 1.4;
    }
}

@media screen and (max-width: 720px) {
    .ampel-cards-container {
    }
    
    .ampel-cards-row {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .ampel-cards-row-cards {
        gap: 8px;
    }
    
    .traffic-light {
        width: 55px;
        padding: 6px;
        min-height: 90px;
        align-self: stretch;
        height: auto;
    }
    
    .traffic-light .traffic-dot {
        width: 28px;
        height: 28px;
        margin: 2px 0;
    }
    
    .traffic-light .traffic-dot::before {
        width: 20px;
        height: 20px;
    }
    
    .ampel-cards-row img.traffic-image {
        flex-shrink: 0 !important;
        align-self: stretch !important;
        height: auto !important;
        object-fit: fill !important;
    }
    
    /* Default width for smaller mobile when no inline style is set */
    .ampel-cards-row img.traffic-image:not([style*="width"]) {
        width: 55px !important;
    }
    
    .ampel-card.first-card {
        min-height: 90px;
        padding: 12px;
        box-sizing: border-box;
        align-self: stretch;
    }
    
    .ampel-cards-row-cards .ampel-card {
        min-height: 90px;
        padding: 12px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .ampel-card strong {
        font-size: 14px;
        line-height: 1.2;
    }
    
    .ampel-card span {
        font-size: 12px;
        line-height: 1.3;
    }
}

@media screen and (max-width: 450px) {
    .ampel-cards-container {
    }
    
    .ampel-cards-row {
        gap: 6px;
        margin-bottom: 17px;
    }
    
    .ampel-cards-row-cards {
        gap: 6px;
    }
    
    .traffic-light {
        width: 50px;
        padding: 5px;
        min-height: 80px;
        align-self: stretch;
        height: auto;
    }
    
    .traffic-light .traffic-dot {
        width: 24px;
        height: 24px;
        margin: 1px 0;
    }
    
    .traffic-light .traffic-dot::before {
        width: 18px;
        height: 18px;
    }
    
    .ampel-cards-row img.traffic-image {
        flex-shrink: 0 !important;
        align-self: stretch !important;
        height: auto !important;
        object-fit: fill !important;
    }
    
    /* Default width for smallest mobile when no inline style is set */
    .ampel-cards-row img.traffic-image:not([style*="width"]) {
        width: 50px !important;
    }
    
    .ampel-card.first-card {
        min-height: 80px;
        padding: 10px;
        font-size: 90%; /* Overall font size reduction */
        box-sizing: border-box;
        align-self: stretch;
    }
    
    .ampel-cards-row-cards .ampel-card {
        min-height: 80px;
        padding: 10px;
        font-size: 90%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .ampel-card strong {
        font-size: 13px;
        line-height: 1.2;
        margin-bottom: 6px;
    }
    
    .ampel-card span {
        font-size: 11px;
        line-height: 1.3;
        margin-top: 6px;
    }
    
    .ampel-cards-list li img {
        margin: 0;
    }
}

/* Traffic Light Colors - Dynamic from CSS variables or inline styles */
.traffic-dot {
    transition: all 0.3s ease;
}

/* No glow effects - clean uniform appearance */

/* Legacy fallback for data-status based styling */
.traffic-light[data-status="green"] .traffic-dot:nth-child(3):not([style]) { 
    background: #28a745; 
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.6); 
}

.traffic-light[data-status="yellow"] .traffic-dot:nth-child(2):not([style]) { 
    background: #ffc107; 
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.6); 
}

.traffic-light[data-status="red"] .traffic-dot:nth-child(1):not([style]) { 
    background: #dc3545; 
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.6); 
}

/* Card Color Variations */
.ampel-card-green {
    background: linear-gradient(135deg, #d4edda, #c3e6cb) !important;
    border-left: 4px solid #28a745;
}

.ampel-card-yellow {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7) !important;
    border-left: 4px solid #ffc107;
}

.ampel-card-red {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb) !important;
    border-left: 4px solid #dc3545;
}

/* Animation Effects */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ampel-cards-list li {
    animation: fadeInUp 0.6s ease forwards;
}

.ampel-cards-list li:nth-child(1) { animation-delay: 0.1s; }
.ampel-cards-list li:nth-child(2) { animation-delay: 0.2s; }
.ampel-cards-list li:nth-child(3) { animation-delay: 0.3s; }
.ampel-cards-list li:nth-child(4) { animation-delay: 0.4s; }
.ampel-cards-list li:nth-child(5) { animation-delay: 0.5s; }
.ampel-cards-list li:nth-child(6) { animation-delay: 0.6s; }

/* Frontend JavaScript for Collapsible Sections */

/* Collapsible Sections - Full Width Display */
.ampel-collapsible-sections {
    margin-top: 30px;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding: 0 20px;
    box-sizing: border-box;
}

/* Mobile optimizations for collapsible sections */
@media screen and (max-width: 769px) {
    .ampel-collapsible-sections {
        margin-top: 20px;
        padding: 0 10px;
    }
}

@media screen and (max-width: 450px) {
    .ampel-collapsible-sections {
        margin-top: 15px;
        padding: 0 5px;
    }
    
    .ampel-collapsible-content {
        font-size: 90%;
    }
    
    .ampel-collapsible-content h1 { font-size: 1.8em; }
    .ampel-collapsible-content h2 { font-size: 1.5em; }
    .ampel-collapsible-content h3 { font-size: 1.3em; }
    .ampel-collapsible-content h4 { font-size: 1.1em; }
    .ampel-collapsible-content h5 { font-size: 1em; }
    .ampel-collapsible-content h6 { font-size: 0.9em; }
}

.ampel-collapsible-section {
    width: 100%;
    margin-bottom: 30px;
    max-width: 100%;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
    visibility: hidden;
}

.ampel-collapsible-section.active {
    max-height: 5000px; /* Large enough to accommodate any content */
    opacity: 1;
    visibility: visible;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
}

.ampel-collapsible-content {
    width: 100%;
    max-width: 100%;
    background: transparent;
    height: auto;
    min-height: auto;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.ampel-collapsible-content h1,
.ampel-collapsible-content h2,
.ampel-collapsible-content h3,
.ampel-collapsible-content h4,
.ampel-collapsible-content h5,
.ampel-collapsible-content h6 {
    color: inherit;
    margin: 20px 0 15px 0;
    font-weight: 600;
}

.ampel-collapsible-content h1 { font-size: 2.2em; }
.ampel-collapsible-content h2 { font-size: 1.8em; }
.ampel-collapsible-content h3 { font-size: 1.5em; }
.ampel-collapsible-content h4 { font-size: 1.3em; }
.ampel-collapsible-content h5 { font-size: 1.1em; }
.ampel-collapsible-content h6 { font-size: 1em; }

.ampel-collapsible-content p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: inherit;
}

.ampel-collapsible-content ul,
.ampel-collapsible-content ol {
    margin: 15px 0;
    padding-left: 30px;
}

.ampel-collapsible-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.ampel-collapsible-content img {
    max-width: 100%;
    height: auto;
    margin: 15px 0;
    border-radius: 4px;
}

.ampel-collapsible-content blockquote {
    border-left: 4px solid #ddd;
    padding-left: 20px;
    margin: 20px 0;
    font-style: italic;
    color: #666;
}

.ampel-collapsible-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    position: relative;
}

.ampel-collapsible-content th,
.ampel-collapsible-content td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

.ampel-collapsible-content th {
    background-color: #f5f5f5;
    font-weight: 600;
}

/* Table Fullscreen Functionality */
.table-controls {
    position: relative;
    margin-bottom: 10px;
}

.table-enlarge-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 10px;
    transition: background-color 0.3s ease;
}

.table-enlarge-btn:hover {
    background: #005a87;
}

.table-enlarge-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Fullscreen table overlay */
.table-fullscreen-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.95) !important;
    z-index: 2147483647 !important; /* Maximum z-index value */
    display: none !important;
    overflow: auto !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

.table-fullscreen-overlay.active {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
}

.table-fullscreen-content {
    background: white !important;
    border-radius: 8px !important;
    padding: 20px !important;
    margin: 20px auto !important;
    width: 95% !important;
    max-width: 95% !important;
    max-height: 90vh !important;
    position: relative !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    overflow: auto !important;
}

.table-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.table-fullscreen-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.table-fullscreen-close {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.table-fullscreen-close:hover {
    background: #c82333;
}

.table-fullscreen-close:focus {
    outline: 2px solid #dc3545;
    outline-offset: 2px;
}

.table-fullscreen-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 14px;
}

.table-fullscreen-table th,
.table-fullscreen-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.table-fullscreen-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-fullscreen-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.table-fullscreen-table tr:hover {
    background-color: #f0f8ff;
}

/* Mobile responsive fullscreen table */
@media screen and (max-width: 768px) {
    .table-fullscreen-overlay {
        padding: 10px;
    }
    
    .table-fullscreen-content {
        max-width: 100%;
        padding: 15px;
    }
    
    .table-fullscreen-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .table-fullscreen-table {
        font-size: 12px;
    }
    
    .table-fullscreen-table th,
    .table-fullscreen-table td {
        padding: 8px;
    }
}

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

/* Print Styles */
@media print {
    .ampel-cards-container {
        max-width: none;
        padding: 0;
    }
    
    .ampel-cards-list li a:hover {
        transform: none;
        box-shadow: none;
    }
    
    .ampel-collapsible-sections {
        display: none;
    }
}