/**
 * KK Sprachnachricht – Frontend Styles
 * Covers: inline widget, floating button, modal overlay
 */

/* ── Widget container ─────────────────────────────────────────────────────── */
.kksp-widget {
    max-width: 520px;
    margin: 0 auto;
    padding: 28px 32px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a1a;
    box-sizing: border-box;
}

/* Inside modal: no outer border/shadow (the panel provides that) */
.kksp-modal-panel .kksp-widget {
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: none;
}

.kksp-title {
    margin: 0 0 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111;
}

.kksp-info {
    margin: 0 0 20px;
    font-size: 0.8125rem;
    color: #777;
    line-height: 1.5;
}

.kksp-privacy-link {
    color: inherit;
    text-decoration: underline;
    white-space: nowrap;
}

.kksp-privacy-link:hover {
    color: #444;
}

/* ── Form fields ──────────────────────────────────────────────────────────── */
.kksp-field {
    margin-bottom: 16px;
}

.kksp-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #444;
}

.kksp-required {
    color: #dc3545;
    margin-left: 2px;
}

.kksp-field input[type="text"],
.kksp-field input[type="email"] {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9375rem;
    color: #1a1a1a;
    background: #fafafa;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    margin-top: 4px;
}

.kksp-field input:focus {
    outline: none;
    border-color: #555;
    background: #fff;
}

/* ── Consent ──────────────────────────────────────────────────────────────── */
.kksp-consent {
    margin-bottom: 22px;
}

.kksp-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.875rem;
    color: #555;
    cursor: pointer;
    line-height: 1.5;
}

.kksp-consent-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ── Recorder area ────────────────────────────────────────────────────────── */
.kksp-recorder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.kksp-record-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Record button */
.kksp-btn-record {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid #ccc;
    background: #f5f5f5;
    color: #444;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0;
    line-height: 1.2;
    text-align: center;
}

.kksp-btn-record:hover:not(:disabled) {
    background: #ffe5e5;
    border-color: #dc3545;
    color: #dc3545;
}

.kksp-btn-record:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.kksp-btn-record:active:not(:disabled) {
    transform: scale(0.96);
}

.kksp-btn-record.kksp-recording {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
    animation: kksp-pulse-btn 1.5s ease-in-out infinite;
}

@keyframes kksp-pulse-btn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    50%       { box-shadow: 0 0 0 14px rgba(220, 53, 69, 0); }
}

/* ── Recording indicator ──────────────────────────────────────────────────── */
.kksp-recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kksp-recording-indicator.kksp-active {
    opacity: 1;
}

.kksp-pulse-ring {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dc3545;
    animation: kksp-blink 1s step-start infinite;
}

@keyframes kksp-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.kksp-timer {
    font-size: 1rem;
    font-weight: 600;
    color: #dc3545;
    font-variant-numeric: tabular-nums;
    min-width: 3ch;
}

.kksp-timer--warning {
    animation: kksp-timer-blink 1s step-start infinite;
}

@keyframes kksp-timer-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

/* ── Audio preview ────────────────────────────────────────────────────────── */
.kksp-preview {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.kksp-preview audio {
    width: 100%;
    border-radius: 6px;
}

.kksp-preview-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Action buttons ───────────────────────────────────────────────────────── */
.kksp-btn-primary,
.kksp-btn-secondary {
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.kksp-btn-primary {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.kksp-btn-primary:hover:not(:disabled) {
    opacity: 0.88;
}

.kksp-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kksp-btn-secondary {
    background: #fff;
    color: #444;
    border-color: #ccc;
}

.kksp-btn-secondary:hover:not(:disabled) {
    background: #f5f5f5;
}

/* ── Status ───────────────────────────────────────────────────────────────── */
.kksp-status {
    width: 100%;
    font-size: 0.875rem;
    min-height: 1.2em;
    text-align: center;
}

.kksp-status--error   { color: #dc3545; }
.kksp-status--success { color: #198754; }
.kksp-status--info    { color: #555; }

/* ── Success message ──────────────────────────────────────────────────────── */
.kksp-success {
    padding: 20px;
    text-align: center;
    font-size: 1rem;
    color: #198754;
    font-weight: 500;
    background: #d1e7dd;
    border-radius: 8px;
}

/* ── Floating button ──────────────────────────────────────────────────────── */
.kksp-float-btn {
    position: fixed;
    bottom: 24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 20px 13px 16px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.kksp-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.kksp-float-btn--small {
    padding: 10px 15px 10px 12px;
    font-size: 0.8rem;
}

.kksp-float-btn--small svg {
    width: 20px;
    height: 20px;
}

.kksp-float-btn--large {
    padding: 16px 26px 16px 20px;
    font-size: 1rem;
}

.kksp-float-btn--large svg {
    width: 32px;
    height: 32px;
}

.kksp-float-btn:active {
    transform: translateY(0);
}

.kksp-float-btn--bottom-right { right: 24px; }
.kksp-float-btn--bottom-left  { left: 24px; }

/* No label → icon-only pill */
.kksp-float-btn:not(:has(.kksp-float-label)) {
    padding: 14px;
    border-radius: 50%;
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */
.kksp-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: flex-end;
    justify-content: center;
}

.kksp-modal.kksp-modal--open {
    display: flex;
}

/* Backdrop */
.kksp-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    animation: kksp-fade-in 0.2s ease;
}

@keyframes kksp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Panel */
.kksp-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 32px 28px 36px;
    box-sizing: border-box;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
    animation: kksp-slide-up 0.25s ease;
}

@keyframes kksp-slide-up {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Close button */
.kksp-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.kksp-modal-close:hover {
    background: #e0e0e0;
    color: #111;
}

/* Prevent body scroll when modal is open */
body.kksp-noscroll {
    overflow: hidden;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .kksp-widget {
        padding: 20px 18px;
    }

    .kksp-btn-record {
        width: 86px;
        height: 86px;
    }

    .kksp-float-btn {
        bottom: 16px;
        padding: 14px;
        border-radius: 50%;
    }

    .kksp-float-btn--small { padding: 10px; }
    .kksp-float-btn--large { padding: 18px; }

    .kksp-float-label {
        display: none;
    }

    .kksp-float-btn--bottom-right { right: 16px; }
    .kksp-float-btn--bottom-left  { left: 16px; }

    .kksp-modal-panel {
        padding: 24px 18px 32px;
        border-radius: 12px 12px 0 0;
    }
}

/* Larger screens: modal as centered card instead of bottom sheet */
@media (min-width: 600px) {
    .kksp-modal {
        align-items: center;
    }

    .kksp-modal-panel {
        border-radius: 16px;
        max-height: 85vh;
    }
}
