/* Dark theme (default) */
:root, .dark {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #18181b;
    --card-hover: #27272a;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --secondary: #27272a;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --border: #27272a;
    --destructive: #7f1d1d;
    --scrollbar-track: #18181b;
    --scrollbar-thumb: #27272a;
    --scrollbar-thumb-hover: #3f3f46;
    --modal-backdrop: rgba(0, 0, 0, 0.8);
}

/* Light theme */
.light {
    --background: #ffffff;
    --foreground: #09090b;
    --card: #f4f4f5;
    --card-hover: #e4e4e7;
    --primary: #18181b;
    --primary-foreground: #fafafa;
    --secondary: #e4e4e7;
    --muted: #e4e4e7;
    --muted-foreground: #71717a;
    --border: #d4d4d8;
    --destructive: #dc2626;
    --scrollbar-track: #f4f4f5;
    --scrollbar-thumb: #d4d4d8;
    --scrollbar-thumb-hover: #a1a1aa;
    --modal-backdrop: rgba(0, 0, 0, 0.5);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Prevent pull-to-refresh on iOS */
body {
    overscroll-behavior-y: contain;
}

/* Safe area for notched phones */
.safe-area-top {
    padding-top: env(safe-area-inset-top);
}
.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Modal backdrop */
.modal-backdrop {
    background: var(--modal-backdrop);
    backdrop-filter: blur(4px);
}

/* Calendar dot - filled (completed doses) */
.dose-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Calendar dot - outlined (upcoming/due doses) */
.dose-dot-upcoming {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid;
}

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

/* Touch manipulation - faster touch response */
.touch-manipulation {
    touch-action: manipulation;
}

/* Input styling for iOS */
input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Smooth theme transition */
body, .bg-background, .bg-card, .bg-secondary, .text-foreground {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Enhanced shadcn-style button classes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    outline: none;
}
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}
.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--foreground);
}
.btn-secondary:hover:not(:disabled) {
    background-color: var(--muted);
}

.btn-destructive {
    background-color: var(--destructive);
    color: #fafafa;
}
.btn-destructive:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-ghost {
    background-color: transparent;
    color: var(--foreground);
}
.btn-ghost:hover:not(:disabled) {
    background-color: var(--secondary);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--foreground);
}
.btn-outline:hover:not(:disabled) {
    background-color: var(--secondary);
}

/* Button sizes */
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}
.btn-icon {
    padding: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
}

/* ============================================================
   Animations
   ============================================================ */

/* Fade in */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Fade in up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Fade in down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
}

/* Scale in */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

/* Staggered animation delays */
.animate-delay-100 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-200 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-300 { animation-delay: 0.3s; opacity: 0; }
.animate-delay-400 { animation-delay: 0.4s; opacity: 0; }
.animate-delay-500 { animation-delay: 0.5s; opacity: 0; }
.animate-delay-600 { animation-delay: 0.6s; opacity: 0; }

/* Pulse animation for CTAs */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.animate-pulse-subtle {
    animation: pulse 2s ease-in-out infinite;
}

/* Float animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in-right {
    animation: slideInRight 0.5s ease-out forwards;
}

/* Modal animations */
.modal-backdrop {
    animation: fadeIn 0.2s ease-out;
}

.modal-backdrop > div > div {
    animation: scaleIn 0.2s ease-out;
}

/* Hover lift effect */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Gradient text */
.gradient-text {
    color: #22c55e;
}

/* Gradient icon (for SVG stroke icons) */
.gradient-icon {
    stroke: url(#icon-gradient);
}

/* Gradient button */
.btn-gradient {
    background: #22c55e;
    color: white;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-gradient:hover {
    opacity: 0.9;
}

.btn-gradient:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Typing cursor animation */
.typing-cursor {
    display: inline-block;
    color: #22c55e;
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

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

/* Gradient border */
.gradient-border {
    position: relative;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: #22c55e;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

/* ============================================================
   Loading States & Skeletons
   ============================================================ */

/* Skeleton shimmer animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--muted) 25%,
        var(--card-hover) 50%,
        var(--muted) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.375rem;
}

.skeleton-text {
    height: 1rem;
    width: 100%;
    border-radius: 0.25rem;
}

.skeleton-text-sm {
    height: 0.75rem;
}

.skeleton-text-lg {
    height: 1.5rem;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    height: 8rem;
    border-radius: 0.75rem;
    background: linear-gradient(90deg, rgba(39, 39, 42, 0.35) 0%, rgba(39, 39, 42, 0.7) 50%, rgba(39, 39, 42, 0.35) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.light .skeleton-card {
    background: linear-gradient(90deg, rgba(228, 228, 231, 0.5) 0%, rgba(228, 228, 231, 0.9) 50%, rgba(228, 228, 231, 0.5) 100%);
}

.skeleton-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
}

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.dark .btn-loading.btn-primary::after {
    border-color: var(--primary-foreground);
    border-right-color: transparent;
}

.light .btn-loading.btn-primary::after {
    border-color: var(--primary-foreground);
    border-right-color: transparent;
}

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

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--background);
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Spinner */
.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--muted);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

.spinner-lg {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
}

/* ============================================================
   Accessibility
   ============================================================ */

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 0.5rem 1rem;
    z-index: 100;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

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

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

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Confirmation Dialog
   ============================================================ */

.confirm-dialog {
    max-width: 400px;
    width: 90%;
}

.confirm-dialog-destructive .confirm-btn {
    background-color: #dc2626;
    color: white;
}

.confirm-dialog-destructive .confirm-btn:hover {
    background-color: #b91c1c;
}

/* ============================================================
   Info Tooltips
   ============================================================ */

.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 4px;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.info-tooltip:hover,
.info-tooltip:focus,
.info-tooltip.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

.info-tooltip-content {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 400;
    color: var(--foreground);
    white-space: normal;
    width: max-content;
    max-width: 200px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}

.info-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
}

.info-tooltip-content::before {
    content: '';
    position: absolute;
    top: calc(100% - 1px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--card);
    z-index: 1;
}

.info-tooltip.active .info-tooltip-content,
.info-tooltip:focus .info-tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* Adjust tooltip position for edge cases */
.info-tooltip-content.tooltip-left {
    left: 0;
    transform: translateX(0);
}

.info-tooltip-content.tooltip-left::after,
.info-tooltip-content.tooltip-left::before {
    left: 12px;
}

.info-tooltip-content.tooltip-right {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.info-tooltip-content.tooltip-right::after,
.info-tooltip-content.tooltip-right::before {
    left: auto;
    right: 12px;
}

/* ============================================================
   Number Pad
   ============================================================ */

/* ============================================================
   Layout Utilities
   ============================================================ */

.page-wrap {
    max-width: 40rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 5rem;
}

.page-wrap-wide {
    max-width: 48rem;
}

@media (min-width: 1024px) {
    .page-wrap {
        max-width: 64rem;
    }
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.page-header-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calendar-card {
    width: 100%;
    max-width: 56rem;
    margin: 0 auto;
}

.section-wrap {
    width: 100%;
    max-width: 56rem;
    margin: 0 auto;
}

.form-error {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 1px solid;
    font-size: 0.875rem;
}

.form-error.hidden {
    display: none;
}

.calendar-day--today {
    background-color: #22c55e;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 10px 18px rgba(34, 197, 94, 0.28);
}

.light .calendar-day--today {
    background-color: #16a34a;
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(22, 163, 74, 0.25);
}
.dark .form-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.light .form-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
    color: #b91c1c;
}

/* ============================================================
   Toggle Switch
   ============================================================ */

.toggle-switch {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: var(--muted);
    border: 1px solid var(--border);
    transition: background-color 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.toggle-switch[aria-pressed="true"] {
    background-color: #22c55e;
    border-color: #22c55e;
}

.toggle-switch-knob {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 9999px;
    background-color: var(--foreground);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.toggle-switch[aria-pressed="true"] .toggle-switch-knob {
    transform: translateX(1.25rem);
    background-color: white;
}

/* ============================================================
   Number Pad
   ============================================================ */

.number-pad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    font-size: 1.25rem;
    font-weight: 500;
    background-color: var(--secondary);
    border: none;
    border-radius: 0.5rem;
    color: var(--foreground);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.1s ease;
}

.number-pad-btn:hover {
    background-color: var(--card-hover);
}

.number-pad-btn:active {
    background-color: var(--muted);
    transform: scale(0.98);
}


.calendar-skeleton {
    padding: 12px;
    border-radius: 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.calendar-skeleton-header {
    height: 20px;
    width: 55%;
    margin: 4px auto 16px;
    border-radius: 9999px;
    background: linear-gradient(90deg, rgba(39, 39, 42, 0.35) 0%, rgba(39, 39, 42, 0.7) 50%, rgba(39, 39, 42, 0.35) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.light .calendar-skeleton-header {
    background: linear-gradient(90deg, rgba(228, 228, 231, 0.5) 0%, rgba(228, 228, 231, 0.9) 50%, rgba(228, 228, 231, 0.5) 100%);
}

.calendar-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}

.calendar-skeleton-cell {
    aspect-ratio: 1 / 1;
    border-radius: 0.75rem;
    background: linear-gradient(90deg, rgba(39, 39, 42, 0.35) 0%, rgba(39, 39, 42, 0.7) 50%, rgba(39, 39, 42, 0.35) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.light .calendar-skeleton-cell {
    background: linear-gradient(90deg, rgba(228, 228, 231, 0.5) 0%, rgba(228, 228, 231, 0.9) 50%, rgba(228, 228, 231, 0.5) 100%);
}


.marketing-wrap {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0 1rem;
}

.marketing-section {
    padding: 2.5rem 0;
}

@media (min-width: 768px) {
    .marketing-section {
        padding: 3.5rem 0;
    }
}


.marketing-hero-title {
    font-size: 2.25rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.02em;
}

@media (min-width: 768px) {
    .marketing-hero-title {
        font-size: 2.75rem;
    }
}

.marketing-hero-subtitle {
    font-size: 1.125rem;
    color: var(--muted-foreground);
    max-width: 48rem;
    margin: 0 auto;
}


.field-error {
    font-size: 0.75rem;
    color: #f87171;
    margin-top: 0.25rem;
}

.light .field-error {
    color: #dc2626;
}


.calendar-skeleton-number {
    width: 18px;
    height: 8px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.35);
}

.light .calendar-skeleton-number {
    background: rgba(9, 9, 11, 0.15);
}

.calendar-skeleton-dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: rgba(34, 197, 94, 0.65);
}

.light .calendar-skeleton-dot {
    background: rgba(22, 163, 74, 0.65);
}
