/* DosageTools - Enhanced Styles */

/* ============================================
   BASE STYLES & RESETS
   ============================================ */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* ============================================
   CALCULATOR INPUT STYLING
   ============================================ */

.calc-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid #d1d5db;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background-color: #f9fafb;
    color: #111827;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.calc-input:hover {
    border-color: #9ca3af;
    background-color: #ffffff;
}

.calc-input:focus {
    outline: none;
    border-color: #22c55e;
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12), inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.calc-input::placeholder {
    color: #9ca3af;
    font-style: normal;
    font-weight: 500;
}

/* Remove number input spinners */
.calc-input::-webkit-inner-spin-button,
.calc-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.calc-input[type=number] {
    -moz-appearance: textfield;
}

/* ============================================
   SELECT STYLING
   ============================================ */

.calc-select {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid #d1d5db;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    background-color: #f9fafb;
    color: #111827;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.calc-select:hover {
    border-color: #9ca3af;
    background-color: #ffffff;
}

.calc-select:focus {
    outline: none;
    border-color: #22c55e;
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12), inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* ============================================
   CALCULATOR BUTTON
   ============================================ */

.calc-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    font-weight: 600;
    font-size: 1.125rem;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.calc-btn:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.35);
}

.calc-btn:active {
    transform: translateY(0);
}

/* ============================================
   RESULT STYLING
   ============================================ */

.calc-result {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 2px solid #86efac;
}

.calc-result-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #16a34a;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    line-height: 1.2;
}

@media (min-width: 640px) {
    .calc-result-value {
        font-size: 3rem;
    }
}

/* ============================================
   SYRINGE VISUAL COMPONENT
   ============================================ */

.syringe-visual {
    max-width: 100%;
    padding: 0.5rem;
}

.syringe-barrel {
    position: relative;
    height: 2.5rem;
    background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px solid #9ca3af;
    border-radius: 0.5rem;
    overflow: hidden;
}

.syringe-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    transition: width 0.3s ease;
    border-radius: 0.375rem 0 0 0.375rem;
}

.syringe-marks {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 0.5rem 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    color: #6b7280;
    pointer-events: none;
}

.syringe-marks span {
    position: relative;
}

.syringe-marks span::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 0.75rem;
    background: #9ca3af;
    margin-bottom: 0.125rem;
}

/* Larger syringe for emphasis */
.syringe-visual-lg .syringe-barrel {
    height: 3.5rem;
}

.syringe-visual-lg .syringe-marks {
    font-size: 0.75rem;
    padding-bottom: 0.375rem;
}

/* ============================================
   FAQ ACCORDION
   ============================================ */

.faq-item {
    border-bottom: 1px solid #f3f4f6;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.9375rem;
    color: #111827;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.faq-question:hover {
    color: #16a34a;
}

.faq-answer {
    padding-bottom: 1.25rem;
    color: #4b5563;
    line-height: 1.7;
    font-size: 0.9375rem;
    display: none;
}

.faq-answer.open {
    display: block;
    animation: fadeIn 0.2s ease;
}

.faq-icon {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    max-width: 1.25rem;
    color: #9ca3af;
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.faq-icon.open {
    transform: rotate(180deg);
    color: #16a34a;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse-soft {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

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

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    header,
    footer,
    .no-print,
    nav,
    .faq-question svg {
        display: none !important;
    }

    .calc-result {
        break-inside: avoid;
        border: 2px solid #000;
        background: #f0fdf4 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .calc-result-value {
        color: #000 !important;
    }

    body {
        font-size: 12pt;
    }

    a {
        text-decoration: none;
        color: inherit;
    }
}

/* ============================================
   FORM HELPERS
   ============================================ */

.form-field {
    margin-bottom: 1.25rem;
}

.form-helper {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.375rem;
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* Input group with unit suffix */
.input-group {
    position: relative;
}

.input-group .calc-input {
    padding-right: 4rem;
}

.input-suffix {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: none;
}

/* ============================================
   CARD STYLES
   ============================================ */

.calc-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

/* ============================================
   BEGINNER-FRIENDLY STEP INDICATORS
   ============================================ */

.step-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: 50%;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.step-indicator-muted {
    background: #e5e7eb;
    color: #6b7280;
}

/* ============================================
   TOOLTIP STYLES
   ============================================ */

.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
    z-index: 50;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   NOTICE/ALERT BOXES
   ============================================ */

.notice {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
}

.notice-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.notice-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.notice-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

/* ============================================
   MOBILE-SPECIFIC ENHANCEMENTS
   ============================================ */

@media (max-width: 639px) {
    .calc-input,
    .calc-select {
        font-size: 1rem;
        padding: 0.875rem 1rem;
    }

    .calc-result-value {
        font-size: 2rem;
    }

    .faq-question {
        font-size: 0.875rem;
        padding: 1rem 1.25rem;
    }

    .syringe-barrel {
        height: 2rem;
    }

    .syringe-marks {
        font-size: 0.5rem;
    }
}

/* Large touch targets for mobile */
@media (pointer: coarse) {
    .calc-input,
    .calc-select,
    .calc-btn,
    .faq-question {
        min-height: 48px;
    }
}

/* ============================================
   DARK MODE SUPPORT (if enabled)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .dark-mode-auto .calc-input,
    .dark-mode-auto .calc-select {
        background-color: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .dark-mode-auto .calc-result {
        background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
        border-color: #059669;
    }

    .dark-mode-auto .calc-result-value {
        color: #34d399;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus visible for keyboard navigation */
.calc-input:focus-visible,
.calc-select:focus-visible,
.calc-btn:focus-visible,
.faq-question:focus-visible {
    outline: 3px solid #22c55e;
    outline-offset: 2px;
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .calc-input,
    .calc-select {
        border-width: 3px;
    }

    .calc-result {
        border-width: 3px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   ARTICLE CONTENT STYLING
   ============================================ */

/* Formula boxes */
.formula-box {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-left: 4px solid #22c55e;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 1rem;
    color: #1e293b;
    overflow-x: auto;
}

.formula-box code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* Example boxes */
.example-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
}

.example-box .example-label {
    display: inline-block;
    background: #fbbf24;
    color: #78350f;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 0.75rem;
}

.example-box p {
    margin: 0.5rem 0;
    color: #92400e;
}

.example-box .example-calc {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background: #fef3c7;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin: 0.75rem 0;
    font-size: 0.9375rem;
    color: #78350f;
}

/* Step styling for articles */
.article-content h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Important callouts */
.callout-important {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
}

.callout-important strong {
    color: #dc2626;
}

.callout-important p {
    color: #991b1b;
    margin: 0;
}

/* Tip callouts */
.callout-tip {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-left: 4px solid #22c55e;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
}

.callout-tip strong {
    color: #16a34a;
}

.callout-tip p {
    color: #166534;
    margin: 0;
}

/* Article prose improvements */
.article-content {
    line-height: 1.8;
    font-size: 1.0625rem;
    color: #374151;
}

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content ul,
.article-content ol {
    margin: 1.25rem 0 1.75rem 1.5rem;
    padding-left: 0.5rem;
}

.article-content li {
    margin-bottom: 0.75rem;
    padding-left: 0.25rem;
}

.article-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-top: 3rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.article-content h2:first-child {
    margin-top: 0;
}

.article-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.article-content h3:has(.step-number) {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.article-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

/* Improve list item labels (like Temperature:, pH:, etc.) */
.article-content li strong:first-child {
    color: #111827;
}

/* Better spacing for consecutive elements */
.article-content h2 + p,
.article-content h3 + p,
.article-content h4 + p {
    margin-top: 0;
}

.article-content .formula-box + p,
.article-content .example-box + p,
.article-content .callout-tip + p,
.article-content .callout-important + p {
    margin-top: 1.5rem;
}

/* ============================================
   DOSE TRACKER STYLES
   ============================================ */

.tracker-tab {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.tracker-tab.active {
    background: #22c55e;
    color: white;
}

.tracker-tab:not(.active) {
    background: #f3f4f6;
    color: #6b7280;
}

.tracker-tab:not(.active):hover {
    background: #e5e7eb;
}

/* Pulse animation for unlogged dose buttons */
@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
    }
}

.dose-btn-pending {
    animation: pulse-border 2s ease-in-out infinite;
}

/* Toast notification */
.tracker-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 60;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Calendar grid */
.calendar-day {
    min-height: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.calendar-day:hover {
    background: #f3f4f6;
}

.calendar-day.is-today {
    outline: 2px solid #22c55e;
    outline-offset: -2px;
    background: #f0fdf4;
}

.calendar-day.all-complete {
    background: #f0fdf4;
}

@media (min-width: 640px) {
    .calendar-day {
        min-height: 4rem;
    }
}
