/* ================================================================
   DmApp WebApp — Floating Action Button (FAB) v3
   SVG radial pie-chart menu + phone dialer pad
   Matching exact design image layout
   ================================================================ */

#dmapp-fab-container { position: fixed; bottom: 0; right: 0; z-index: 99999; pointer-events: none; }
#dmapp-fab-container * { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* Overlay */
.fab-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.85); backdrop-filter: blur(6px);
    opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none; z-index: 99998;
}
.fab-open .fab-overlay { opacity: 1; visibility: visible; pointer-events: auto; }

/* ── FAB Trigger Button (American Flag Star) ── */
.fab-trigger-btn {
    position: fixed; bottom: 20px; right: 20px; width: 82px; height: 82px;
    border: none; cursor: pointer; padding: 0;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s, filter 0.3s;
    pointer-events: auto; z-index: 100001;
    animation: fab-star-glow 2.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(178,34,52,0.5)) drop-shadow(0 0 10px rgba(60,59,110,0.5));
}
.fab-trigger-btn svg { width: 100%; height: 100%; }
.fab-trigger-btn:hover { transform: scale(1.15); filter: drop-shadow(0 0 18px rgba(178,34,52,0.8)) drop-shadow(0 0 18px rgba(60,59,110,0.8)); }
.fab-trigger-btn.fab-active {
    animation: none;
    filter: drop-shadow(0 0 16px rgba(60,59,110,0.7)) drop-shadow(0 0 16px rgba(178,34,52,0.7));
    transform: scale(1.08);
}

@keyframes fab-star-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(178,34,52,0.5)) drop-shadow(0 0 6px rgba(60,59,110,0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(60,59,110,0.8)) drop-shadow(0 0 20px rgba(178,34,52,0.6)); }
}

/* ── Menu Panel (radial + dialer) — centered on screen ── */
.fab-menu-panel {
    position: fixed; top: 50%; left: 50%;
    width: 380px; max-height: 96vh;
    display: flex; flex-direction: column; align-items: center;
    background: #ffffff; border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.22);
    transform: translate(-50%, -50%) scale(0.3); opacity: 0; visibility: hidden;
    transform-origin: center center;
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s, visibility 0.25s;
    pointer-events: none; z-index: 100000;
    overflow: hidden;
}
.fab-open .fab-menu-panel { transform: translate(-50%, -50%) scale(1); opacity: 1; visibility: visible; pointer-events: auto; }

/* Radial SVG wrap */
.fab-radial-wrap { width: 100%; display: flex; justify-content: center; padding: 10px 10px 4px; background: white; border-radius: 20px 20px 0 0; }
.fab-radial-svg { width: 260px; height: 260px; }
.fab-seg { transition: opacity 0.15s, filter 0.15s; }
.fab-seg:hover { opacity: 0.82; filter: brightness(1.08); }

/* Dialer wrap */
.fab-dialer-wrap { width: 100%; padding: 4px 20px 10px; background: #ffffff; border-radius: 0 0 20px 20px; }

.fab-dialer-display {
    display: flex; align-items: center; justify-content: center;
    padding: 4px 8px; min-height: 28px; gap: 8px;
}
.fab-dialer-number {
    font-size: 18px; font-weight: 500; color: #222; letter-spacing: 2px;
    font-family: 'SF Mono', 'Fira Code', monospace; min-height: 24px;
}
.fab-dialer-backspace {
    background: none; border: none; font-size: 20px; cursor: pointer;
    color: #666; padding: 4px 8px; border-radius: 8px; transition: background 0.15s;
}
.fab-dialer-backspace:hover { background: #e0e0e0; color: #333; }

.fab-dialer-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 2px 8px;
}
.fab-dialer-key {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    aspect-ratio: 1; border-radius: 50%;
    background: linear-gradient(145deg, #eaeaea, #d8d8d8);
    border: none; cursor: pointer;
    box-shadow: 3px 3px 8px rgba(0,0,0,0.1), -2px -2px 6px rgba(255,255,255,0.8);
    transition: transform 0.1s, box-shadow 0.1s;
}
.fab-dialer-key:hover { background: linear-gradient(145deg, #ddd, #ccc); transform: scale(0.96); }
.fab-dialer-key:active { transform: scale(0.9); box-shadow: inset 2px 2px 4px rgba(0,0,0,0.12); }
.fab-key-num { font-size: 22px; font-weight: 400; color: #444; line-height: 1.1; }
.fab-key-letters { font-size: 8px; font-weight: 600; color: #999; letter-spacing: 2px; }

.fab-dialer-actions { display: flex; justify-content: center; gap: 16px; padding: 6px 0 4px; }
.fab-dial-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
    font-size: 20px; display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
}
.fab-dial-action {
    background: linear-gradient(135deg, #C6FF00, #76FF03);
    box-shadow: 0 3px 10px rgba(198,255,0,0.4);
    color: #333;
}
.fab-dial-btn:hover { transform: scale(1.08); }
.fab-dial-btn:active { transform: scale(0.95); }

/* ── Toast ── */
.fab-toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #1a1a1a; color: white; padding: 10px 24px; border-radius: 28px;
    font-size: 14px; font-weight: 500; opacity: 0; visibility: hidden;
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    z-index: 100002; pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.fab-toast-show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ── Dark Mode — Force white backgrounds for FAB ── */
@media (prefers-color-scheme: dark) {
    .fab-menu-panel { background: #ffffff !important; }
    .fab-radial-wrap { background: #ffffff !important; }
    .fab-dialer-wrap { background: #ffffff !important; }
    .fab-dialer-number { color: #222 !important; }
    .fab-dialer-backspace { color: #666 !important; }
    .fab-dialer-key { background: linear-gradient(145deg, #eaeaea, #d8d8d8) !important; box-shadow: 3px 3px 8px rgba(0,0,0,0.1), -2px -2px 6px rgba(255,255,255,0.8) !important; }
    .fab-dialer-key:hover { background: linear-gradient(145deg, #ddd, #ccc) !important; }
    .fab-key-num { color: #444 !important; }
    .fab-key-letters { color: #999 !important; }
    .fab-toast { background: #1a1a1a; }
    .fab-overlay { background: rgba(255,255,255,0.85) !important; }
}

/* ── Contacts Bar (between radial and dialer) ── */
.fab-contacts-bar { width: 100%; display: flex; justify-content: center; padding: 2px 20px; }
.fab-contacts-btn {
    width: 100%; padding: 8px; border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb); color: #1565C0;
    font-size: 14px; font-weight: 600; transition: background 0.2s, transform 0.15s;
}
.fab-contacts-btn:hover { background: linear-gradient(135deg, #bbdefb, #90caf9); transform: scale(1.02); }

/* ── IT Call Panel ── */
.fab-it-panel, .fab-contacts-panel {
    position: fixed; top: 50%; left: 50%; width: 380px; max-height: 90vh;
    background: #fff; border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.22);
    transform: translate(-50%, -50%) scale(0.3); opacity: 0; visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s, visibility 0.25s;
    z-index: 100000; overflow: hidden; display: flex; flex-direction: column;
}
.fab-it-panel.fab-panel-open, .fab-contacts-panel.fab-panel-open {
    transform: translate(-50%, -50%) scale(1); opacity: 1; visibility: visible; pointer-events: auto;
}
.fab-it-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: linear-gradient(135deg, #1a237e, #283593);
    color: #fff; border-radius: 16px 16px 0 0;
}
.fab-it-title { font-size: 15px; font-weight: 700; }
.fab-it-close {
    background: rgba(255,255,255,0.2); border: none; color: #fff; width: 28px; height: 28px;
    border-radius: 50%; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.fab-it-close:hover { background: rgba(255,255,255,0.4); }
.fab-it-body { padding: 12px 16px; overflow-y: auto; max-height: 70vh; }
.fab-it-section { margin-bottom: 8px; }
.fab-it-label { font-size: 13px; font-weight: 700; color: #333; display: block; margin-bottom: 4px; }
.fab-it-desc { font-size: 11px; color: #777; margin: 0 0 6px; line-height: 1.4; }
.fab-it-select {
    width: 100%; padding: 8px 10px; border: 1.5px solid #ddd; border-radius: 8px;
    font-size: 13px; background: #fafafa; color: #333; cursor: pointer; transition: border-color 0.2s;
}
.fab-it-select:focus { border-color: #1565C0; outline: none; }
.fab-it-swap {
    display: block; margin: 4px auto; padding: 4px 16px; border: 1.5px solid #1565C0;
    border-radius: 20px; background: transparent; color: #1565C0; font-size: 12px;
    font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.fab-it-swap:hover { background: #e3f2fd; }
.fab-it-divider { height: 1px; background: #eee; margin: 10px 0; }
.fab-it-btn {
    width: 100%; padding: 10px; border: none; border-radius: 10px; cursor: pointer;
    font-size: 13px; font-weight: 600; transition: transform 0.15s, opacity 0.15s;
}
.fab-it-btn:hover { transform: scale(1.02); }
.fab-it-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.fab-it-detect-btn { background: linear-gradient(135deg, #e8eaf6, #c5cae9); color: #283593; }
.fab-it-start-btn { background: linear-gradient(135deg, #1a237e, #283593); color: #fff; font-size: 15px; margin-top: 4px; }
.fab-it-merge-btn { background: linear-gradient(135deg, #fff3e0, #ffe0b2); color: #e65100; padding: 8px 14px; width: auto; }

/* Voice status */
.fab-it-voice-status { margin-bottom: 6px; }
.fab-it-voice-badge {
    display: inline-block; padding: 4px 12px; border-radius: 16px;
    font-size: 12px; font-weight: 600; background: #eee; color: #666;
}
.fab-it-voice-male { background: #e3f2fd; color: #1565C0; }
.fab-it-voice-female { background: #fce4ec; color: #c62828; }

/* Progress bar */
.fab-it-progress-wrap { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fab-it-progress-bar { flex: 1; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.fab-it-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #1565C0, #42a5f5); border-radius: 3px; transition: width 0.1s; }
.fab-it-progress-text { font-size: 11px; font-weight: 600; color: #1565C0; min-width: 30px; }

/* Upload area */
.fab-it-upload-area {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px; border: 2px dashed #ccc; border-radius: 10px; cursor: pointer;
    transition: border-color 0.2s, background 0.2s; text-align: center;
}
.fab-it-upload-area:hover { border-color: #1565C0; background: #f5f8ff; }
.fab-it-upload-icon { font-size: 24px; }
.fab-it-upload-text { font-size: 11px; color: #888; }

/* Avatar merge */
.fab-it-avatar-row { display: flex; align-items: center; gap: 12px; }
.fab-it-avatar-preview {
    width: 52px; height: 52px; border-radius: 50%; background: #e8eaf6;
    display: flex; align-items: center; justify-content: center; font-size: 26px;
    border: 2px solid #c5cae9;
}
.fab-it-avatar-info { flex: 1; }
.fab-it-avatar-status { display: block; font-size: 12px; font-weight: 600; color: #666; margin-bottom: 6px; }

/* ── Contacts Panel ── */
.fab-contacts-search { padding: 8px 12px; }
.fab-contacts-input {
    width: 100%; padding: 8px 12px; border: 1.5px solid #ddd; border-radius: 8px;
    font-size: 13px; background: #fafafa; box-sizing: border-box;
}
.fab-contacts-input:focus { border-color: #1565C0; outline: none; }
.fab-contacts-list { overflow-y: auto; max-height: 50vh; padding: 0 12px 12px; }
.fab-contact-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: 10px; transition: background 0.15s; cursor: default;
}
.fab-contact-item:hover { background: #f5f5f5; }
.fab-contact-avatar {
    width: 36px; height: 36px; border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.fab-contact-info { flex: 1; min-width: 0; }
.fab-contact-name { display: block; font-size: 13px; font-weight: 600; color: #333; }
.fab-contact-phone { display: block; font-size: 11px; color: #888; }
.fab-contact-actions { display: flex; gap: 4px; }
.fab-contact-act {
    width: 30px; height: 30px; border: none; border-radius: 50%; cursor: pointer;
    font-size: 14px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.fab-contact-act:hover { background: #e0e0e0; transform: scale(1.1); }

/* Dark Mode overrides for IT/Contacts panels */
@media (prefers-color-scheme: dark) {
    .fab-it-panel, .fab-contacts-panel { background: #fff !important; }
    .fab-it-body { background: #fff !important; }
    .fab-it-label { color: #333 !important; }
    .fab-it-select { background: #fafafa !important; color: #333 !important; }
    .fab-contacts-input { background: #fafafa !important; color: #333 !important; }
    .fab-contact-name { color: #333 !important; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .fab-trigger-btn { bottom: 14px; right: 14px; width: 68px; height: 68px; }
    .fab-menu-panel { width: calc(100vw - 24px); }
    .fab-radial-svg { width: 220px; height: 220px; }
    .fab-dialer-wrap { padding: 6px 16px 12px; }
    .fab-key-num { font-size: 24px; }
}

@media (min-width: 768px) {
    .fab-menu-panel { width: 400px; }
    .fab-radial-svg { width: 280px; height: 280px; }
}
