/* ╔════════════════════════════════════════════════════════════════╗
   ║  Sadhana - Mobile-first Time Tracker                          ║
   ║  Uses CSS variables from themes/*.css                          ║
   ╚════════════════════════════════════════════════════════════════╝ */

/* Import themes */
@import url('./themes/dust-term.css');
@import url('./themes/dust-term-light.css');

/* Base */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-bg);
    color: var(--color-fg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Paper grain texture overlay - fixed size, no scaling */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
}

/* Safe area padding for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pb-safe-b {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Tab button states */
.tab-btn.active {
    color: var(--color-accent);
}

.tab-btn.active i {
    transform: scale(1.1);
}

/* Animations */
@keyframes slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-slide-up {
    animation: slide-up 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

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

/* Custom Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--color-bg-warm);
    border-radius: 0;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-accent);
    border-radius: 0;
    cursor: pointer;
    border: 2px solid var(--color-bg);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-accent);
    border-radius: 0;
    cursor: pointer;
    border: 2px solid var(--color-bg);
}

input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 30%, transparent);
}

/* noUiSlider Theme */
.noUi-target {
    border: none !important;
    background: var(--color-bg-warm) !important;
    box-shadow: none !important;
    height: 6px !important;
    border-radius: 0 !important;
}

.noUi-connects {
    border-radius: 0 !important;
}

.noUi-connect {
    background: var(--color-secondary) !important;
}

.noUi-horizontal .noUi-handle {
    width: 16px !important;
    height: 16px !important;
    right: -8px !important;
    top: -5px !important;
    border: 2px solid var(--color-bg) !important;
    border-radius: 0 !important;
    background: var(--color-accent) !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

.noUi-handle:before,
.noUi-handle:after {
    display: none !important;
}

/* KC Impact Slider Colors */
.kc-impact .noUi-target {
    background: var(--color-bg-warm) !important;
}

.kc-impact .noUi-connect {
    background: currentColor !important;
}

.kc-impact[data-value^="-"] .noUi-connect {
    color: var(--color-error) !important;
}

.kc-impact[data-value^="-"] .noUi-handle {
    background: var(--color-error) !important;
}

.kc-impact:not([data-value^="-"]) .noUi-connect {
    color: var(--color-success) !important;
}

.kc-impact:not([data-value^="-"]) .noUi-handle {
    background: var(--color-success) !important;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--color-fg-gutter);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-fg-dark);
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Selection */
::selection {
    background: var(--color-bg-visual);
    color: var(--color-fg);
}

/* Focus */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Button press effect */
button:active:not(:disabled) {
    transform: scale(0.98);
}

/* Disabled state */
button:disabled,
input:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Select dropdown arrow */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor' opacity='0.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Tabular numbers for timer */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Modal backdrop blur support */
@supports (backdrop-filter: blur(4px)) {
    .modal {
        backdrop-filter: blur(4px);
    }
}

/* Pulse animation for live indicator */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* Highcharts theme overrides */
.highcharts-background {
    fill: transparent !important;
}

.highcharts-title,
.highcharts-subtitle {
    fill: var(--color-fg) !important;
}

.highcharts-axis-title,
.highcharts-axis-labels text {
    fill: var(--color-fg-dark) !important;
}

.highcharts-legend-item text {
    fill: var(--color-fg) !important;
}

.highcharts-tooltip-box {
    fill: var(--color-bg-popup) !important;
    stroke: var(--color-bg-visual) !important;
}

.highcharts-grid-line {
    stroke: var(--color-bg-highlight) !important;
}

/* Touch-friendly sizing */
@media (hover: none) and (pointer: coarse) {
    .touch-target {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Prevent text selection on UI elements */
nav, button, .tab-btn {
    user-select: none;
    -webkit-user-select: none;
}

/* Smooth transitions */
.transition-colors {
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* ╔════════════════════════════════════════════════════════════════╗
   ║  SUBTLE DEPTH EFFECTS                                          ║
   ╚════════════════════════════════════════════════════════════════╝ */

/* Primary action buttons - subtle raised effect */
.btn-primary,
button.bg-g-green,
button.bg-g-red,
button.bg-g-blue,
button.bg-g-orange {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-primary:active,
button.bg-g-green:active,
button.bg-g-red:active,
button.bg-g-blue:active,
button.bg-g-orange:active {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Timer display - letterpress effect */
.timer-display {
    text-shadow:
        0 1px 1px rgba(0, 0, 0, 0.4),
        0 -1px 0 rgba(255, 255, 255, 0.03);
}

/* Headings - subtle depth */
h1, h2 {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

/* Stats numbers - inset look */
.text-2xl.font-bold,
.text-xl.font-bold,
.text-lg.font-bold {
    text-shadow:
        0 1px 1px rgba(0, 0, 0, 0.25),
        0 -1px 0 rgba(255, 255, 255, 0.02);
}

/* Active tab text */
.tab-btn.active,
.settings-tab.active {
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Category name in player */
.category-name {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* Sidebar active item */
.sidebar-nav-btn.active {
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

/* Input fields - very subtle inset */
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
select,
textarea {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Modal cards - floating */
.modal-content > div {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

/* ╔════════════════════════════════════════════════════════════════╗
   ║  LIGHT THEME SPECIFIC STYLES                                   ║
   ║  Add shadows and borders for better visual separation          ║
   ╚════════════════════════════════════════════════════════════════╝ */

/* Light theme cards - subtle shadow */
html.light .bg-g-bg-s {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Light theme primary buttons */
html.light .btn-primary,
html.light button.bg-g-green,
html.light button.bg-g-red,
html.light button.bg-g-blue,
html.light button.bg-g-orange {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

html.light .btn-primary:active,
html.light button.bg-g-green:active,
html.light button.bg-g-red:active,
html.light button.bg-g-blue:active,
html.light button.bg-g-orange:active {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Light theme text - embossed effect (inverted shadows) */
html.light .timer-display {
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.7),
        0 -1px 1px rgba(0, 0, 0, 0.05);
}

html.light h1,
html.light h2 {
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

html.light .text-2xl.font-bold,
html.light .text-xl.font-bold,
html.light .text-lg.font-bold {
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

html.light .tab-btn.active,
html.light .settings-tab.active {
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

html.light .category-name {
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

html.light .sidebar-nav-btn.active {
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Modals get stronger shadow */
html.light .modal-backdrop > div {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Dropdown menus */
html.light #settings-lang-menu {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Buttons in light mode */
html.light .bg-g-bg-1 {
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Settings tabs container */
html.light .settings-tab.bg-g-bg-1 {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Input fields border enhancement */
html.light input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
html.light select,
html.light textarea {
    border-color: rgba(0, 0, 0, 0.12) !important;
}

html.light input:focus,
html.light select:focus,
html.light textarea:focus {
    border-color: var(--color-accent) !important;
    box-shadow: 0 0 0 3px rgba(74, 138, 96, 0.15);
}

/* Color picker special styling */
html.light input[type="color"] {
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
}


/* ╔════════════════════════════════════════════════════════════════╗
   ║  TIME PLAYER STYLES                                            ║
   ╚════════════════════════════════════════════════════════════════╝ */

/* Dark theme - semi-transparent dark overlay */
.time-player {
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Dark theme timer text - white for contrast */
.time-player .timer-display {
    color: #ffffff;
}

/* Dark theme category name */
.time-player .category-name {
    color: rgba(255, 255, 255, 0.8);
}

/* Light theme - solid white card */
html.light .time-player {
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Light theme timer text - dark */
html.light .time-player .timer-display {
    color: var(--color-fg);
}

/* Light theme category name */
html.light .time-player .category-name {
    color: var(--color-fg-dim);
}

/* Light theme - plus button needs border */
html.light .time-player .btn-operation {
    border-color: rgba(0, 0, 0, 0.15);
}

html.light .time-player .btn-operation:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.25);
}

/* Light theme dropdown */
html.light .time-player .dropdown {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* ╔════════════════════════════════════════════════════════════════╗
   ║  DESKTOP SIDEBAR STYLES                                        ║
   ╚════════════════════════════════════════════════════════════════╝ */

/* Sidebar nav item active state */
.sidebar-nav-btn.active {
    background-color: var(--color-bg-warm);
    color: var(--color-accent);
    border-left: 3px solid var(--color-accent);
    margin-left: -3px;
}

.sidebar-nav-btn.active i {
    color: var(--color-accent);
}

/* Light theme sidebar */
html.light aside {
    background: #ffffff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.06);
}

html.light .sidebar-nav-btn.active {
    background-color: rgba(74, 138, 96, 0.1);
    box-shadow: inset 3px 0 0 var(--color-accent);
}
