/**
 * LSL Script Dialog Styles
 * Positioned in top-right corner with slide-in animation
 * Compatible with VR (will be mirrored in 3D HUD)
 */

/* Container for all script dialogs - top right stacking */
#script-dialog-container {
    position: fixed;
    top: 80px; /* Below toolbar */
    right: 20px;
    z-index: 15000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    pointer-events: none; /* Allow click-through when empty */
}

#script-dialog-container > * {
    pointer-events: auto; /* Re-enable for actual dialogs */
}

/* Individual script dialog */
.script-dialog {
    background: linear-gradient(135deg, #0a3d62 0%, #0c5a8a 100%);
    border: 2px solid #3498db;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(52, 152, 219, 0.3);
    padding: 16px;
    color: white;
    font-family: 'Segoe UI', Arial, sans-serif;
    animation: slideInFromRight 0.3s ease-out;
    transform-origin: right center;
    min-width: 280px;
    max-width: 360px;
}

.script-dialog.closing {
    animation: slideOutToRight 0.3s ease-in forwards;
}

/* Dialog header */
.script-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.script-dialog-object-name {
    font-size: 14px;
    font-weight: 600;
    color: #3498db;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-dialog-owner {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
}

.script-dialog-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.script-dialog-close:hover {
    color: #e74c3c;
}

/* Dialog message */
.script-dialog-message {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.95);
    max-height: 150px;
    overflow-y: auto;
    word-wrap: break-word;
}

/* Button grid - match Second Life's button layout */
.script-dialog-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.script-dialog-buttons.single-row {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
}

/* Individual dialog button */
.script-dialog-btn {
    background: linear-gradient(180deg, #2980b9 0%, #1a5276 100%);
    border: 1px solid #3498db;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 32px;
}

.script-dialog-btn:hover {
    background: linear-gradient(180deg, #3498db 0%, #2980b9 100%);
    border-color: #5dade2;
    transform: translateY(-1px);
}

.script-dialog-btn:active {
    transform: translateY(0);
    background: #1a5276;
}

/* Ignore button - styled differently */
.script-dialog-ignore {
    background: linear-gradient(180deg, #7f8c8d 0%, #5d6d7e 100%);
    border: 1px solid #95a5a6;
    border-radius: 4px;
    color: white;
    font-size: 11px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 4px;
    align-self: flex-end;
}

.script-dialog-ignore:hover {
    background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
    border-color: #e74c3c;
}

/* Footer with timeout indicator */
.script-dialog-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.script-dialog-timeout {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.script-dialog-timeout-bar {
    height: 2px;
    background: rgba(52, 152, 219, 0.3);
    border-radius: 1px;
    margin-top: 8px;
    overflow: hidden;
}

.script-dialog-timeout-progress {
    height: 100%;
    background: #3498db;
    width: 100%;
    animation: timeout-shrink 60s linear forwards;
}

/* Animations */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutToRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

@keyframes timeout-shrink {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Permission dialog specific styles */
.script-dialog.permission-dialog {
    border-color: #f39c12;
}

.script-dialog.permission-dialog .script-dialog-object-name {
    color: #f39c12;
}

.permission-list {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    margin: 10px 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.permission-list li {
    margin: 4px 0;
    padding-left: 4px;
}

/* Teleport request dialog */
.script-dialog.teleport-dialog {
    border-color: #9b59b6;
}

.script-dialog.teleport-dialog .script-dialog-object-name {
    color: #9b59b6;
}

.teleport-destination {
    font-size: 12px;
    color: #bb8fce;
    margin-bottom: 8px;
    font-weight: 500;
}

/* Mobile / VR friendly sizing */
@media (max-width: 480px), (pointer: coarse) {
    #script-dialog-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .script-dialog {
        min-width: auto;
        max-width: none;
    }
    
    .script-dialog-btn {
        padding: 12px 8px;
        font-size: 14px;
        min-height: 44px; /* Touch-friendly */
    }
    
    .script-dialog-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}
