/* ============================================================
   Fusion Clock - Systray Icon & Dropdown Panel
   Top-right navbar clock widget with pulse 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);
}

// ---- 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);
}

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

$fclk-gradient: linear-gradient(135deg, $fclk-teal 0%, #2563eb 100%);
$fclk-gradient-active: linear-gradient(135deg, $fclk-green 0%, $fclk-teal 100%);

// ===========================================================
// Systray Icon & Dropdown
// ===========================================================

.fclk-systray-btn {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.fclk-systray-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;

    .fa-clock-o {
        font-size: 16px;
        position: relative;
        z-index: 1;
        transition: color 0.3s;
    }

    &--in {
        .fa-clock-o {
            color: var(--bs-success, var(--o-success, #198754));
        }

        &::before,
        &::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            border: 1.5px solid var(--bs-success, var(--o-success, #198754));
            transform: translate(-50%, -50%) scale(1);
            animation: fclk-wave 2.4s infinite ease-out;
        }

        &::after {
            animation-delay: 1.2s;
        }
    }

    &--out {
        .fa-clock-o {
            color: var(--bs-danger, var(--o-danger, #dc3545));
        }
    }
}

@keyframes fclk-wave {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.8);
        opacity: 0;
    }
}

.fclk-systray-dropdown {
    width: 280px;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: var(--fclk-fab-panel-shadow) !important;
}

.fclk-systray-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--fclk-fab-panel-bg);
}

.fclk-systray-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fclk-systray-header-dot {
    font-size: 8px;
    flex-shrink: 0;
}

.fclk-systray-header-text {
    font-weight: 600;
    font-size: 13px;
    color: var(--fclk-fab-text);
}

.fclk-systray-link {
    margin-left: auto;
    color: var(--fclk-fab-muted);
    font-size: 12px;
    &:hover { color: var(--fclk-fab-text); }
}

.fclk-systray-location {
    font-size: 12px;
    color: var(--fclk-fab-muted);
    .fa { margin-right: 4px; }
}

.fclk-systray-timer {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    color: var(--fclk-fab-text);
    font-variant-numeric: tabular-nums;
    padding: 4px 0;
}

.fclk-systray-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px;
    background: var(--fclk-fab-location-bg);
    border-radius: 8px;
}

.fclk-systray-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

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

.fclk-systray-stat-lbl {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--fclk-fab-muted);
}

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

.fclk-systray-action {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.15s, transform 0.1s;
    color: #fff;

    &--in {
        background: var(--bs-success, var(--o-success, #198754));
        &:hover { opacity: 0.9; }
    }

    &--out {
        background: var(--bs-danger, var(--o-danger, #dc3545));
        &:hover { opacity: 0.9; }
    }

    &:active { transform: scale(0.98); }
    &:disabled { opacity: 0.6; cursor: not-allowed; }
}

.fclk-systray-error {
    padding: 8px 12px;
    background: var(--fclk-fab-error-bg);
    border-radius: 6px;
    font-size: 12px;
    color: var(--bs-warning, var(--o-warning, #856404));
    .fa { margin-right: 4px; }
}

// ===========================================================
// 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);
    }
}

.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; }
}

.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;
}

.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; }
}

.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; }
}

.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; }
}

.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; }
}

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);
    }
}
