/* ===========================================
   TibiaTrack - Main Stylesheet
   =========================================== */

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ---- CSS Variables ---- */
:root {
    /* Brand colors */
    --brand-primary: #556ee6;
    --brand-success: #34c38f;
    --brand-warning: #f1b44c;
    --brand-danger: #f46a6a;
    --brand-info: #50a5f1;

    /* Slate palette (light mode) */
    --color-body: #f1f5f9;
    --color-panel: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #334155;
    --color-text-muted: #64748b;
}

/* Dark mode colors */
.dark {
    --color-body: #0a0f1a;
    --color-panel: #1e293b;
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
}

/* ---- Base Styles ---- */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--color-body);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* ---- Focus styles ---- */
*:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ---- Selection ---- */
::selection {
    background-color: var(--brand-primary);
    color: white;
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.2s ease-out;
}

.animate-slideIn {
    animation: slideIn 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ---- Utility Classes ---- */
.glass {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.gradient-text {
    background: linear-gradient(135deg, var(--brand-primary), #a972cb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-balance {
    text-wrap: balance;
}

/* ---- Toast Notifications ---- */
.toast {
    animation: slideIn 0.3s ease-out;
}

.toast-success {
    background-color: var(--brand-success);
}

.toast-error {
    background-color: var(--brand-danger);
}

.toast-warning {
    background-color: var(--brand-warning);
}

.toast-info {
    background-color: var(--brand-info);
}

/* ---- Loading States ---- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-border) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        var(--color-border) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ---- Print Styles ---- */
@media print {
    header, footer, nav {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Boss Cards ---- */

/* Glow effects for high probability boss cards */
.boss-card-glow-red {
    position: relative;
}

.boss-card-glow-red::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), 0 0 40px rgba(239, 68, 68, 0.1);
    pointer-events: none;
    z-index: 0;
    opacity: 1;
}

.boss-card-glow-red:hover::before {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4), 0 0 60px rgba(239, 68, 68, 0.2);
}

/* Slow pulse animation for guaranteed spawns — GPU-composited (opacity only) */
@keyframes pulse-slow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse-slow {
    position: relative;
}

.animate-pulse-slow::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5), 0 0 60px rgba(239, 68, 68, 0.3);
    pointer-events: none;
    z-index: 0;
    animation: pulse-slow 2s ease-in-out infinite;
    will-change: opacity;
}

/* ====== Boss card timeline — axis view ====== */

.boss-tl {
    position: relative;
    margin-bottom: 0.25rem;
    min-height: 25px;
    contain: layout;
}

/* ── Track ── */
.boss-tl__track {
    position: relative;
    height: 10px;
    min-height: 10px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 5px;
    overflow: visible;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Phase 1 — Cooldown: striped dark zone = "don't bother" */
.boss-tl__cooldown {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 5px 0 0 5px;
    background:
        repeating-linear-gradient(
            -45deg,
            rgba(100, 116, 139, 0.18) 0px,
            rgba(100, 116, 139, 0.18) 2px,
            transparent 2px,
            transparent 6px
        ),
        linear-gradient(to right, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.85));
}

/* Phase 2 — Spawn window: gradient glow = "boss spawns here" */
.boss-tl__window {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 0 5px 5px 0;
    background: linear-gradient(
        to right,
        rgba(85, 110, 230, 0.05),
        rgba(85, 110, 230, 0.18)
    );
}

/* Separator tick between cooldown and window */
.boss-tl__window::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1px;
    bottom: 1px;
    width: 1px;
    background: rgba(85, 110, 230, 0.25);
}

/* ── AVG marker — dashed vertical line + tag ── */
.boss-tl__avg {
    position: absolute;
    top: -3px;
    bottom: -15px;
    width: 0;
    border-left: 1.5px dashed rgba(148, 163, 184, 0.45);
    z-index: 10;
    pointer-events: none;
}

.boss-tl__avg-tag {
    position: absolute;
    bottom: 0;
    left: 0;
    transform: translateX(-50%);
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: rgba(148, 163, 184, 0.7);
    line-height: 1;
    pointer-events: none;
    user-select: none;
    background: rgba(15, 23, 42, 0.85);
    padding: 0 3px;
    border-radius: 2px;
}

/* ── Today dot — glowing marker = "we are here" ── */
.boss-tl__dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    z-index: 20;
    transition: left 0.5s ease;
    /* Clamp position so dot never overflows the track edges */
    left: clamp(4%, var(--dot-pos, 0%), 96%);
    will-change: transform, left;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Gray — Cooldown */
.boss-tl__dot--gray {
    background: #475569;
    border-color: rgba(100, 116, 139, 0.6);
    box-shadow: 0 0 4px rgba(71, 85, 105, 0.5);
}

/* Blue — Low */
.boss-tl__dot--blue {
    background: #3b82f6;
    border-color: rgba(147, 197, 253, 0.7);
    box-shadow:
        0 0 6px rgba(59, 130, 246, 0.45),
        0 0 14px rgba(59, 130, 246, 0.12);
}

/* Yellow — Medium */
.boss-tl__dot--yellow {
    background: #eab308;
    border-color: rgba(253, 224, 71, 0.8);
    box-shadow:
        0 0 8px rgba(234, 179, 8, 0.5),
        0 0 18px rgba(234, 179, 8, 0.18);
}

/* Orange — High */
.boss-tl__dot--orange {
    background: #f97316;
    border-color: rgba(251, 191, 36, 0.8);
    box-shadow:
        0 0 10px rgba(249, 115, 22, 0.5),
        0 0 20px rgba(249, 115, 22, 0.18);
}

/* Red — Critical (≥80% / guaranteed) + pulse */
.boss-tl__dot--red {
    background: #ef4444;
    border-color: rgba(252, 165, 165, 0.9);
    box-shadow:
        0 0 10px rgba(239, 68, 68, 0.6),
        0 0 24px rgba(239, 68, 68, 0.25);
    animation: tl-dot-pulse 2s ease-in-out infinite;
}

@keyframes tl-dot-pulse {
    0%, 100% {
        box-shadow:
            0 0 10px rgba(239, 68, 68, 0.6),
            0 0 24px rgba(239, 68, 68, 0.25);
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        box-shadow:
            0 0 16px rgba(239, 68, 68, 0.85),
            0 0 32px rgba(239, 68, 68, 0.4);
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* ── Labels ── */
.boss-tl__labels {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 4px;
    height: 11px;
    font-size: 9px;
    line-height: 11px;
    color: rgba(100, 116, 139, 0.65);
    user-select: none;
}

.boss-tl__labels span {
    flex-shrink: 0;
}

.boss-tl__label-mid {
    position: absolute !important;
    transform: translateX(-50%);
    color: rgba(85, 110, 230, 0.5);
    font-size: 8px;
}

/* ====== Boss card priority borders ====== */

/* Cards "Bardzo wysoka" (≥90%) — red border highlight */
.boss-card--critical {
    border-color: rgba(239, 68, 68, 0.3) !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.08);
}

/* Cards "Wysoka" (70-89%) — orange border highlight */
.boss-card--high {
    border-color: rgba(249, 115, 22, 0.2) !important;
}

/* ====== Killed boss card — muted overlay ====== */
.boss-card--killed {
    position: relative;
    opacity: 0.55;
    filter: saturate(0.3);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.boss-card--killed:hover {
    opacity: 0.8;
    filter: saturate(0.6);
}

/* ====== History page — card glow effects ====== */

.boss-card.ring-green-500\/50,
.boss-card.ring-purple-500\/50 {
    position: relative;
}

.boss-card.ring-green-500\/50::before,
.boss-card.ring-purple-500\/50::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    animation: glow-pulse 2s ease-in-out infinite alternate;
    will-change: opacity;
}

.boss-card.ring-green-500\/50::before {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.boss-card.ring-purple-500\/50::before {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

@keyframes glow-pulse {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* Date input styling for dark theme */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

/* ====== PWA standalone mode fixes ====== */
@media (display-mode: standalone) {
    .boss-tl {
        min-height: 25px;
        visibility: visible !important;
        display: block !important;
    }

    .boss-tl__track {
        min-height: 10px;
        visibility: visible !important;
        display: block !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    .boss-tl__cooldown,
    .boss-tl__window {
        visibility: visible !important;
        display: block !important;
    }

    .boss-tl__dot {
        visibility: visible !important;
        display: block !important;
        -webkit-transform: translate(-50%, -50%);
        transform: translate(-50%, -50%);
    }

    .boss-tl__labels {
        visibility: visible !important;
        display: flex !important;
    }
}

