/* ============================================================
   Fusion Clock - Floating Action Button (FAB)
   Bottom-left corner clock widget with ripple animation
   Theme-aware: adapts to Odoo light / dark mode
   ============================================================ */

// ---- Light-mode tokens (default) ----
:root {
    --fclk-fab-panel-bg: #ffffff;
    --fclk-fab-panel-border: #e5e7eb;
    --fclk-fab-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --fclk-fab-text: #1f2937;
    --fclk-fab-muted: #6b7280;
    --fclk-fab-divider: #e5e7eb;
    --fclk-fab-location-bg: rgba(16, 185, 129, 0.08);
    --fclk-fab-error-bg: rgba(239, 68, 68, 0.06);
    --fclk-fab-arrow-bg: #ffffff;
}

// ---- Dark-mode tokens ----
html.o_dark {
    --fclk-fab-panel-bg: #1e2028;
    --fclk-fab-panel-border: #3a3d48;
    --fclk-fab-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --fclk-fab-text: #f1f1f4;
    --fclk-fab-muted: #9ca3af;
    --fclk-fab-divider: #3a3d48;
    --fclk-fab-location-bg: rgba(16, 185, 129, 0.1);
    --fclk-fab-error-bg: rgba(239, 68, 68, 0.1);
    --fclk-fab-arrow-bg: #1e2028;
}

// Static color palette
$fclk-teal: #0d9488;
$fclk-blue: #3b82f6;
$fclk-green: #10B981;
$fclk-red: #ef4444;

// Gradient used on the FAB (teal-to-blue like the portal header)
$fclk-gradient: linear-gradient(135deg, $fclk-teal 0%, #2563eb 100%);
$fclk-gradient-active: linear-gradient(135deg, $fclk-green 0%, $fclk-teal 100%);

// ===========================================================
// Wrapper - anchored bottom-LEFT
// ===========================================================
.fclk-fab-wrapper {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    pointer-events: none;

    > * { pointer-events: auto; }
}

// ===========================================================
// FAB Button
// ===========================================================
.fclk-fab-btn {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: $fclk-gradient;
    color: #fff;
    font-size: 21px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba($fclk-teal, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    overflow: visible;

    &:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 28px rgba($fclk-teal, 0.45);
    }

    &:active {
        transform: scale(0.93);
    }

    // Clocked-in: green-teal gradient
    &.fclk-fab-btn--active {
        background: $fclk-gradient-active;
        box-shadow: 0 4px 20px rgba($fclk-green, 0.4);

        &:hover {
            box-shadow: 0 6px 28px rgba($fclk-green, 0.5);
        }
    }

    // Panel-open: muted
    &.fclk-fab-btn--open {
        background: #374151;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        color: #d1d5db;
    }

    .fclk-fab-icon {
        position: relative;
        z-index: 2;
        transition: transform 0.3s ease;
        line-height: 1;
    }

    &.fclk-fab-btn--open .fclk-fab-icon {
        transform: rotate(90deg);
    }
}

// ---- Ripple rings radiating outward from the FAB ----
.fclk-fab-ripple-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 2px solid rgba($fclk-green, 0.5);
    transform: translate(-50%, -50%) scale(1);
    pointer-events: none;
    z-index: 1;

    &.fclk-fab-ripple-ring--1 {
        animation: fclk-ripple-out 2.4s ease-out infinite;
    }
    &.fclk-fab-ripple-ring--2 {
        animation: fclk-ripple-out 2.4s ease-out 0.8s infinite;
    }
    &.fclk-fab-ripple-ring--3 {
        animation: fclk-ripple-out 2.4s ease-out 1.6s infinite;
    }
}

@keyframes fclk-ripple-out {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.55;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.6);
        opacity: 0;
    }
}

// ---- Mini timer badge ----
.fclk-fab-badge {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: $fclk-green;
    font-size: 9px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    letter-spacing: 0.5px;
    border: 1px solid rgba($fclk-green, 0.35);
    pointer-events: none;
    z-index: 3;
    animation: fclk-badge-in 0.3s ease;
}

@keyframes fclk-badge-in {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

// ===========================================================
// Expanded Panel
// ===========================================================
.fclk-fab-panel {
    width: 280px;
    background: var(--fclk-fab-panel-bg);
    border: 1px solid var(--fclk-fab-panel-border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--fclk-fab-panel-shadow);
    animation: fclk-panel-slide-up 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

@keyframes fclk-panel-slide-up {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

// Arrow pointing down toward the FAB
.fclk-fab-panel-arrow {
    position: absolute;
    bottom: -6px;
    left: 22px;
    width: 12px;
    height: 12px;
    background: var(--fclk-fab-arrow-bg);
    border-right: 1px solid var(--fclk-fab-panel-border);
    border-bottom: 1px solid var(--fclk-fab-panel-border);
    transform: rotate(45deg);
}

// ---- Header row ----
.fclk-fab-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.fclk-fab-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--fclk-fab-text);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.fclk-fab-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    flex-shrink: 0;

    &.active {
        background: $fclk-green;
        box-shadow: 0 0 6px rgba($fclk-green, 0.5);
    }
}

.fclk-fab-open-link {
    color: var(--fclk-fab-muted);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;

    &:hover { color: $fclk-blue; }
}

// ---- Location chip ----
.fclk-fab-location {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: $fclk-green;
    background: var(--fclk-fab-location-bg);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 12px;

    .fa { font-size: 12px; }
}

// ---- Timer ----
.fclk-fab-timer {
    text-align: center;
    color: var(--fclk-fab-text);
    font-size: 28px;
    font-weight: 300;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
    margin-bottom: 14px;
    line-height: 1;
}

// ---- Stats row ----
.fclk-fab-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 14px;
}

.fclk-fab-stat {
    text-align: center;

    .fclk-fab-stat-val {
        display: block;
        color: var(--fclk-fab-text);
        font-size: 16px;
        font-weight: 700;
    }

    .fclk-fab-stat-lbl {
        display: block;
        color: var(--fclk-fab-muted);
        font-size: 9px;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        margin-top: 2px;
    }
}

.fclk-fab-stat-divider {
    width: 1px;
    height: 28px;
    background: var(--fclk-fab-divider);
}

// ---- Action button ----
.fclk-fab-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 11px 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;

    .fa { font-size: 15px; }

    &.fclk-fab-action--in {
        background: $fclk-gradient;
        color: #fff;

        &:hover:not(:disabled) {
            box-shadow: 0 4px 16px rgba($fclk-teal, 0.4);
        }
    }

    &.fclk-fab-action--out {
        background: $fclk-red;
        color: #fff;

        &:hover:not(:disabled) {
            box-shadow: 0 4px 16px rgba($fclk-red, 0.35);
        }
    }

    &:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }
}

// ---- Error ----
.fclk-fab-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: $fclk-red;
    font-size: 11px;
    background: var(--fclk-fab-error-bg);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 10px;
    animation: fclk-shake 0.35s ease;
    line-height: 1.4;

    .fa { font-size: 12px; margin-top: 1px; flex-shrink: 0; }
}

@keyframes fclk-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

// ===========================================================
// FAB Dialog Overlays (reason, clock-out confirmation)
// ===========================================================
.fclk-fab-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fclk-fab-dialog-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
}

.fclk-fab-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--fclk-fab-panel-bg);
    border: 1px solid var(--fclk-fab-panel-border);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: fclk-dialog-enter 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 85vh;
    overflow-y: auto;

    &.fclk-fab-dialog--compact {
        max-width: 360px;
    }
}

@keyframes fclk-dialog-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.fclk-fab-dialog-header {
    padding: 28px 24px 20px;
    text-align: center;
    border-bottom: 1px solid var(--fclk-fab-panel-border);
}

.fclk-fab-dialog-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 22px;
}

.fclk-fab-dialog-header--warning .fclk-fab-dialog-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.fclk-fab-dialog-header--danger .fclk-fab-dialog-icon {
    background: rgba($fclk-red, 0.12);
    color: $fclk-red;
}

.fclk-fab-dialog-title {
    color: var(--fclk-fab-text);
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.3px;
}

.fclk-fab-dialog-subtitle {
    color: var(--fclk-fab-muted);
    font-size: 12px;
    line-height: 1.5;
    margin: 0;
}

.fclk-fab-dialog-body {
    padding: 20px 24px;
}

.fclk-fab-dialog-field {
    margin-bottom: 16px;

    &:last-child {
        margin-bottom: 0;
    }
}

.fclk-fab-dialog-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--fclk-fab-text);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;

    .fa { color: var(--fclk-fab-muted); font-size: 13px; }
}

.fclk-fab-dialog-required {
    color: $fclk-red;
    font-weight: 700;
}

.fclk-fab-dialog-input {
    width: 100%;
    background: var(--fclk-fab-location-bg, rgba(0, 0, 0, 0.04));
    border: 1.5px solid var(--fclk-fab-panel-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--fclk-fab-text);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;

    &:focus {
        border-color: $fclk-green;
        box-shadow: 0 0 0 3px rgba($fclk-green, 0.15);
    }

    &::placeholder {
        color: var(--fclk-fab-muted);
    }
}

.fclk-fab-dialog-hint {
    display: block;
    color: var(--fclk-fab-muted);
    font-size: 10px;
    margin-top: 4px;
}

.fclk-fab-dialog-footer {
    padding: 14px 24px 18px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid var(--fclk-fab-panel-border);
}

.fclk-fab-dialog-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;

    &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .fa { font-size: 13px; }
}

.fclk-fab-dialog-btn--cancel {
    background: transparent;
    color: var(--fclk-fab-muted);
    border: 1px solid var(--fclk-fab-panel-border);

    &:hover:not(:disabled) {
        background: var(--fclk-fab-location-bg);
        color: var(--fclk-fab-text);
    }
}

.fclk-fab-dialog-btn--submit {
    background: $fclk-gradient-active;
    color: #fff;
    box-shadow: 0 2px 8px rgba($fclk-green, 0.3);

    &:hover:not(:disabled) {
        box-shadow: 0 4px 16px rgba($fclk-green, 0.4);
        transform: translateY(-1px);
    }
}

.fclk-fab-dialog-btn--danger {
    background: $fclk-red;
    color: #fff;
    box-shadow: 0 2px 8px rgba($fclk-red, 0.3);

    &:hover:not(:disabled) {
        box-shadow: 0 4px 16px rgba($fclk-red, 0.4);
        transform: translateY(-1px);
    }
}

// Summary card (used in clock-out confirmation)
.fclk-fab-dialog-summary {
    background: var(--fclk-fab-location-bg, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--fclk-fab-panel-border);
    border-radius: 10px;
    padding: 14px;
}

.fclk-fab-dialog-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;

    + .fclk-fab-dialog-summary-row {
        border-top: 1px solid var(--fclk-fab-panel-border);
    }
}

.fclk-fab-dialog-summary-label {
    color: var(--fclk-fab-muted);
    font-size: 12px;
}

.fclk-fab-dialog-summary-value {
    color: var(--fclk-fab-text);
    font-size: 13px;
    font-weight: 600;
}

// ===========================================================
// Location Map Widget
// ===========================================================
.fclk-map-widget {
    width: 100%;
    margin: 8px 0;
}

.fclk-map-container {
    display: block;
    border: 1px solid var(--fclk-fab-panel-border, #e5e7eb);
}

.fclk-map-loading,
.fclk-map-error,
.fclk-map-placeholder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px dashed var(--fclk-fab-panel-border, #e5e7eb);
}

.fclk-map-loading {
    color: var(--fclk-fab-muted, #6b7280);
    background: rgba(59, 130, 246, 0.04);
}

.fclk-map-error {
    color: $fclk-red;
    background: rgba($fclk-red, 0.04);
}

.fclk-map-placeholder {
    color: var(--fclk-fab-muted, #6b7280);
    background: rgba(0, 0, 0, 0.02);
}

html.o_dark {
    .fclk-map-loading { background: rgba(59, 130, 246, 0.08); }
    .fclk-map-error { background: rgba($fclk-red, 0.08); }
    .fclk-map-placeholder { background: rgba(255, 255, 255, 0.03); }
}

.fclk-map-hint {
    text-align: center;
    padding: 6px 12px;
    font-size: 11px;
    color: var(--fclk-fab-muted, #6b7280);

    .fa { margin-right: 4px; }
}

// Google Places dropdown z-index fix
.pac-container {
    z-index: 2100 !important;
    border-radius: 8px;
    margin-top: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    font-family: inherit;
}

.fclk-places-input {
    width: 100%;
}

// ===========================================================
// Dashboard Summary Cards
// ===========================================================
.fclk-dash-card {
    position: relative;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;

    &:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }
}

.fclk-dash-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.fclk-dash-card-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.fclk-dash-card-label {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

// -- Total (blue/slate) --
.fclk-dash-card--total {
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
    border: 1px solid #bfdbfe;

    .fclk-dash-card-icon { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
    .fclk-dash-card-value { color: #1e3a5f; }
    .fclk-dash-card-label { color: #3b82f6; }
}

// -- Present (green) --
.fclk-dash-card--present {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;

    .fclk-dash-card-icon { background: rgba(16, 185, 129, 0.15); color: #059669; }
    .fclk-dash-card-value { color: #064e3b; }
    .fclk-dash-card-label { color: #10b981; }
}

// -- Absent (red) --
.fclk-dash-card--absent {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;

    .fclk-dash-card-icon { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
    .fclk-dash-card-value { color: #7f1d1d; }
    .fclk-dash-card-label { color: #ef4444; }
}

// -- Late (amber) --
.fclk-dash-card--late {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;

    .fclk-dash-card-icon { background: rgba(245, 158, 11, 0.15); color: #d97706; }
    .fclk-dash-card-value { color: #78350f; }
    .fclk-dash-card-label { color: #f59e0b; }
}

// -- Dark mode overrides --
html.o_dark {
    .fclk-dash-card--total {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(99, 102, 241, 0.1) 100%);
        border-color: rgba(59, 130, 246, 0.25);
        .fclk-dash-card-value { color: #93c5fd; }
        .fclk-dash-card-label { color: #60a5fa; }
        .fclk-dash-card-icon { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
    }

    .fclk-dash-card--present {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.08) 100%);
        border-color: rgba(16, 185, 129, 0.25);
        .fclk-dash-card-value { color: #6ee7b7; }
        .fclk-dash-card-label { color: #34d399; }
        .fclk-dash-card-icon { background: rgba(16, 185, 129, 0.2); color: #34d399; }
    }

    .fclk-dash-card--absent {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(248, 113, 113, 0.08) 100%);
        border-color: rgba(239, 68, 68, 0.25);
        .fclk-dash-card-value { color: #fca5a5; }
        .fclk-dash-card-label { color: #f87171; }
        .fclk-dash-card-icon { background: rgba(239, 68, 68, 0.18); color: #f87171; }
    }

    .fclk-dash-card--late {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.08) 100%);
        border-color: rgba(245, 158, 11, 0.25);
        .fclk-dash-card-value { color: #fcd34d; }
        .fclk-dash-card-label { color: #fbbf24; }
        .fclk-dash-card-icon { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
    }

    .fclk-dash-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    }
}
