/**
 * 12S MESOMONSTER - Design System v18
 * Premium dark glassmorphism with orange accent
 */

:root {
    --color-bg-base: #020202;
    --color-bg-surface: #0a0a0a;
    --color-bg-glass: rgba(20, 20, 20, 0.6);
    --color-primary: #f97316;
    --color-primary-hover: #fb923c;
    --color-primary-glow: rgba(249, 115, 22, 0.4);
    --color-success: #22c55e;
    --color-success-glow: rgba(34, 197, 94, 0.4);
    --color-danger: #ef4444;
    --color-text-primary: #ffffff;
    --color-text-secondary: #9ca3af;
    --color-text-muted: #6b7280;
    --color-border-subtle: rgba(255, 255, 255, 0.08);

    /* Legacy aliases */
    --bg-base: var(--color-bg-base);
    --bg-surface: var(--color-bg-surface);
    --primary: var(--color-primary);
    --primary-glow: var(--color-primary-glow);
    --success: var(--color-success);
    --success-glow: var(--color-success-glow);
    --text-main: var(--color-text-primary);
    --text-sec: var(--color-text-secondary);
    --border-glass: var(--color-border-subtle);
    --bg-glass: var(--color-bg-glass);
    --border-subtle: var(--color-border-subtle);

    --radius-pill: 999px;
    --radius-card: 24px;
    --radius-lg: 16px;
    --font-inter: 'Inter', sans-serif;
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--color-bg-base);
    background-image: radial-gradient(circle at 50% 0%, #1a0b02 0%, var(--color-bg-base) 60%);
    background-attachment: fixed;
    color: var(--color-text-primary);
    font-family: var(--font-inter);
    margin: 0;
    padding-bottom: 100px;
    min-height: 100vh;
    line-height: 1.5;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 900;
    font-style: italic;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.page-title {
    font-size: 1.5rem;
    margin-top: 0.25rem;
}

.section-title {
    font-size: 1.2rem;
    opacity: 0.8;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: 1.8rem;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    max-width: 200px;
}

.text-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.text-orange {
    color: var(--color-primary);
    text-shadow: 0 0 10px var(--color-primary-glow);
}

.text-green {
    color: var(--color-success);
    text-shadow: 0 0 10px var(--color-success-glow);
}

.text-sec {
    color: var(--color-text-secondary);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.container {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.flex-row {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-2 {
    gap: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* Cards */
.glass-card {
    background: var(--color-bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.hero-card {
    border: 1px solid var(--color-primary);
}

.hero-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), transparent);
    z-index: -1;
}

.hero-content {
    flex: 1;
}

.card-success {
    border-color: var(--color-success);
}

.celebration-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.pill-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-card);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.pill-card:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.06);
}

.squircle-card {
    background: var(--color-bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* KPI */
.kpi-row {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.kpi-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border-subtle);
    border-radius: 16px;
    padding: 10px;
    text-align: center;
}

.kpi-val {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
}

.kpi-lbl {
    font-size: 0.6rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
}

/* Tip */
.tip-card {
    padding: 1.25rem;
}

.tip-icon {
    font-size: 1.2rem;
    margin-right: 8px;
}

.tip-text {
    font-size: 1rem;
    line-height: 1.5;
    font-style: italic;
    opacity: 0.9;
    margin: 0;
}

/* Buttons */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    padding: 1rem 2rem;
    font-weight: 800;
    font-style: italic;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 0 20px var(--color-primary-glow);
    transition: all 0.2s var(--ease-spring);
    display: inline-block;
    width: 100%;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-success {
    background: var(--color-success);
    box-shadow: 0 0 20px var(--color-success-glow);
}

/* Inputs */
input,
.input-field {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border-subtle);
    color: #fff;
    padding: 1rem;
    border-radius: var(--radius-pill);
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
}

input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-glow);
}

/* Avatar */
.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-border-subtle);
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-lg {
    width: 56px;
    height: 56px;
}

.avatar-xl {
    width: 100px;
    height: 100px;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initial {
    font-weight: 800;
    color: var(--color-primary);
    font-size: 1.2rem;
}

.avatar-xl .avatar-initial {
    font-size: 2.5rem;
    font-style: italic;
}

/* Progress Ring */
.progress-ring {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(var(--color-primary) var(--progress, 0%), rgba(255, 255, 255, 0.1) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--color-primary-glow);
    flex-shrink: 0;
}

.progress-ring::before {
    content: '';
    position: absolute;
    width: 52px;
    height: 52px;
    background: var(--color-bg-surface);
    border-radius: 50%;
}

.progress-value {
    position: relative;
    font-weight: 800;
    font-size: 0.9rem;
    color: #fff;
}

/* Tab Bar */
.tab-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-pill);
    display: flex;
    justify-content: space-around;
    padding: 12px;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.7;
    transition: all 0.2s;
    padding: 4px 12px;
}

.tab-item.active {
    color: var(--color-primary);
    opacity: 1;
}

.tab-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.tab-item.active .tab-icon {
    filter: drop-shadow(0 0 8px var(--color-primary-glow));
}

.tab-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Utilities */
.glow-header {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .tab-bar {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border-subtle);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s var(--ease-spring);
}

.toast-visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-hiding {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
}

.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-success);
}

.toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

.toast-warning .toast-icon {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.toast-info .toast-icon {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.toast-pr .toast-icon {
    background: rgba(249, 115, 22, 0.2);
    color: var(--color-primary);
    font-size: 18px;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

/* ========================================
   BOTTOM SHEET
   ======================================== */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bottom-sheet-overlay.visible {
    opacity: 1;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-surface);
    border-radius: 24px 24px 0 0;
    padding: 8px 24px 32px;
    z-index: 2001;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s var(--ease-spring);
}

.bottom-sheet.visible {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 8px auto 20px;
}

.bottom-sheet-content {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ========================================
   SKELETON LOADERS
   ======================================== */
.skeleton-card {
    background: var(--color-bg-glass);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    border-radius: 8px;
    margin-bottom: 12px;
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-line-lg {
    width: 80%;
    height: 20px;
}

.skeleton-line-md {
    width: 60%;
}

.skeleton-line-sm {
    width: 40%;
}

.skeleton-line-xs {
    width: 30%;
    height: 12px;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-circle-lg {
    width: 60px;
    height: 60px;
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.skeleton-exercise {
    background: var(--color-bg-glass);
    border-radius: var(--radius-card);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.skeleton-kpi {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

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

    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   PULL TO REFRESH
   ======================================== */
.pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    z-index: 3000;
    transition: transform 0.2s, opacity 0.2s;
}

.pull-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
}

.pull-indicator.refreshing .pull-spinner {
    animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   BADGE / PILL COMPONENT
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-secondary);
}

.badge-primary {
    background: rgba(249, 115, 22, 0.2);
    color: var(--color-primary);
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

.badge-pr {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.3), rgba(234, 179, 8, 0.3));
    color: #fbbf24;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes glow-pulse {

    0%,
    100% {
        box-shadow: 0 0 10px var(--color-primary-glow);
    }

    50% {
        box-shadow: 0 0 25px var(--color-primary-glow);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

.scale-in {
    animation: scaleIn 0.3s var(--ease-spring);
}

.pulse {
    animation: pulse 2s infinite;
}

.glow-pulse {
    animation: glow-pulse 2s infinite;
}

.bounce {
    animation: bounce 1s infinite;
}

/* ========================================
   LOADING STATE
   ======================================== */
.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

/* ========================================
   HOVER EFFECTS (Desktop)
   ======================================== */
@media (hover: hover) {
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 25px var(--color-primary-glow);
    }

    .glass-card:hover {
        border-color: rgba(255, 255, 255, 0.15);
    }

    .pill-card:hover {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.12);
    }

    .tab-item:hover {
        opacity: 1;
        color: var(--color-primary);
    }
}

/* ========================================
   PWA STANDALONE MODE
   ======================================== */
.pwa-standalone body,
.ios-standalone body {
    /* Extra padding for status bar */
    padding-top: env(safe-area-inset-top, 0);
}

.pwa-standalone .container,
.ios-standalone .container {
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0));
}

/* Hide install prompt in standalone */
.pwa-standalone #install-prompt,
.ios-standalone #install-prompt {
    display: none !important;
}

/* Fullscreen app feel */
@media (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }

    /* Prevent pull-to-refresh on iOS */
    html {
        overflow: hidden;
        height: 100%;
    }

    body {
        overflow: auto;
        height: 100%;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {

    .tab-bar,
    #install-prompt,
    .btn-primary {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .glass-card {
        background: #f5f5f5;
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

/* ========================================
   PAGE TRANSITIONS
   ======================================== */
.page-exit {
    animation: pageExit 0.2s ease-out forwards;
}

.page-enter {
    animation: pageEnter 0.3s ease-out forwards;
}

@keyframes pageExit {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.98);
    }
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: scale(1.02);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* View Transitions API (Chrome 111+) */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: 0.2s ease-out both viewFadeOut;
}

::view-transition-new(root) {
    animation: 0.3s ease-out both viewFadeIn;
}

@keyframes viewFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes viewFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Named transitions for specific elements */
.hero-card {
    view-transition-name: hero-card;
}

.tab-bar {
    view-transition-name: tab-bar;
}

::view-transition-old(tab-bar),
::view-transition-new(tab-bar) {
    animation: none;
}