/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-block;
    width: auto;
}

/* For buttons, make the container not affect layout */
button + .tooltip-container {
    position: absolute;
    margin-top: -52px;
    margin-left: 10px;
    width: auto;
    pointer-events: auto;
}

/* Position tooltip to the right for buttons */
button + .tooltip-container .tooltip-box {
    bottom: auto;
    left: 100%;
    top: -5px;
    margin-left: 10px;
}

button + .tooltip-container .tooltip-box::after {
    top: 10px;
    left: -5px;
    border-left-color: #2c3e50;
    border-right-color: transparent;
}

.tooltip-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: #3498db;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: help;
    margin-left: 5px;
    font-weight: bold;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.tooltip-icon:hover {
    background: #2980b9;
    transform: scale(1.15);
}

.tooltip-box {
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    white-space: normal;
    line-height: 1.4;
}

.tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #2c3e50;
}

.tooltip-box.visible {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Keep CSS hover for enhanced UX */
.tooltip-icon:hover ~ .tooltip-box,
.tooltip-box:hover,
.tooltip-icon:hover .tooltip-box,
.tooltip-container:hover .tooltip-box {
    opacity: 1;
    visibility: visible;
}

/* Adjust tooltip position for small screens */
@media (max-width: 480px) {
    .tooltip-box {
        white-space: normal;
        max-width: calc(100vw - 40px);
        bottom: auto;
        top: 125%;
    }

    .tooltip-box::after {
        top: auto;
        bottom: 100%;
        border-top-color: transparent;
        border-bottom-color: #2c3e50;
    }
}

/* Label with tooltip */
.label-with-tooltip {
    display: flex;
    align-items: center;
    gap: 0;
}

.label-with-tooltip label {
    margin: 0;
    flex: 1;
}

.label-with-tooltip .tooltip-icon {
    margin-left: 5px;
    flex-shrink: 0;
}

/* Ensure labels with tooltips have proper positioning context */
label[data-tooltip] {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Required field indicator */
.field-required::before {
    content: '*';
    color: #e74c3c;
    margin-right: 3px;
}
