/**
 * ServiceNow Request Widget – self-contained styles.
 * No shared CSS with other widgets or the chat UI.
 */

.servicenow-request-widget {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10); /* Match desk booking widget */
    border: none; /* Let the shadow define the card edge, like desk booking */
    margin: 1rem 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden; /* Ensure header shares the same rounded top corners */
}

.sn-request-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #e2e8f0; /* One step darker for stronger contrast */
}

.sn-request-title {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #0f172a;
}

.sn-request-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: #4a5568;
}

.sn-request-body {
    padding: 1.25rem 1.5rem 1.4rem 1.5rem;
}

.sn-request-description {
    margin: 0.1rem 0 0 0;
    font-size: 0.9rem;
    color: #4a5568;
}

.sn-request-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #4a5568;
}

.sn-request-loading--hidden {
    display: none;
}

.sn-request-loading-spinner {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid #cbd5e0;
    border-top-color: #4c6fff;
    animation: sn-request-spin 0.7s linear infinite;
}

@keyframes sn-request-spin {
    to {
        transform: rotate(360deg);
    }
}

.sn-request-error {
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #742a2a;
    font-size: 0.85rem;
    line-height: 1.3;
}

.sn-request-error--hidden {
    display: none;
}

.sn-request-form {
    margin: 0;
}

.sn-request-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.sn-request-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sn-request-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #1a202c;
}

.sn-request-required {
    color: #e53e3e;
    margin-left: 0.25rem;
}

.sn-request-input,
.sn-request-select,
.sn-request-textarea {
    border-radius: 10px;
    border: 1px solid #cbd5e0; /* Match desk booking inputs for clearer, consistent borders */
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
    color: #0f172a;
    background: #ffffff;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.sn-request-input:focus,
.sn-request-select:focus,
.sn-request-textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.2);
    background: #ffffff;
}

.sn-request-textarea {
    resize: vertical;
    min-height: 72px;
}

/* ── Date field — styled span + hidden native input (mirrors book-meeting widget) ── */

.sn-request-date-wrapper {
    position: relative;
}

.sn-request-date-display {
    display: block;
    cursor: pointer;
    user-select: none;
}

.sn-request-date-display:hover {
    border-color: #6b7280;
}

.sn-request-date-native {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    border: none;
    padding: 0;
    margin: 0;
}

.sn-request-widget--disabled .sn-request-date-display {
    color: #9ca3af;
    cursor: not-allowed;
}

.sn-request-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.sn-request-status {
    font-size: 0.8rem;
    color: #4a5568;
}

.sn-request-submit-btn {
    border-radius: 999px; /* Keep pill shape, but align colors with primary buttons */
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.92rem;
    font-weight: 500;
    color: #ffffff;
    background: #667eea; /* Match primary chat / desk booking accent */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.35);
    transition: transform 0.08s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.sn-request-submit-btn:hover:not(:disabled) {
    transform: translateY(-0.5px);
    background: #5a67d8;
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.35);
}

.sn-request-submit-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 3px 6px rgba(66, 153, 225, 0.35);
}

.sn-request-submit-btn:disabled {
    opacity: 0.6;
    cursor: default;
    box-shadow: none;
}

.sn-request-toast {
    margin-top: 0.75rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: rgba(56, 161, 105, 0.08);
    border: 1px solid rgba(56, 161, 105, 0.35);
    color: #22543d;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sn-request-toast::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #38a169;
}

.sn-request-toast--hidden {
    display: none;
}

.sn-request-widget--disabled,
.servicenow-request-widget.sn-request-widget--disabled {
    opacity: 0.9;
}

.sn-request-widget--disabled .sn-request-input,
.sn-request-widget--disabled .sn-request-select,
.sn-request-widget--disabled .sn-request-textarea {
    background: #edf2f7;
    cursor: not-allowed;
}

@media (min-width: 640px) {
    .sn-request-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sn-request-field:nth-child(1),
    .sn-request-field:nth-child(4) {
        grid-column: span 2;
    }
}

