/* PEPTIDE CALCULATOR - BASE STYLES
 * Mobile-first, theme-agnostic, performance-optimized
 * Theme colors injected via CSS variables from /calculator/themes/*.css
 */

/* ========== CSS VARIABLES (Overridden by Themes) ========== */
:root {
    --calc-bg: #FFFFFF;
    --calc-text: #1F2937;
    --calc-text-muted: #6B7280;
    --calc-accent: #8B5CF6;
    --calc-accent-hover: #7C3AED;
    --calc-border: #E5E7EB;
    --calc-surface: #F9FAFB;
    --calc-error: #EF4444;
    --calc-warning: #F59E0B;
    --calc-success: #10B981;
    --calc-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --calc-radius: 8px;
}

/* ========== RESET & BASE ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: var(--calc-bg);
    color: var(--calc-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ========== NAVIGATION ========== */
.calc-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--calc-border);
    background: var(--calc-bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-link,
.help-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--calc-border);
    border-radius: var(--calc-radius);
    background: transparent;
    color: var(--calc-text);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.back-link:hover,
.help-btn:hover {
    background: var(--calc-surface);
    border-color: var(--calc-accent);
}

/* ========== MAIN CONTAINER ========== */
.calc-container {
    max-width: 600px; /* Single-column centered on ALL screen sizes */
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ========== HEADER ========== */
.calc-header {
    text-align: center;
    margin-bottom: 2rem;
}

.calc-header h1 {
    font-size: 28px;
    font-weight: 400;
    color: var(--calc-text);
    margin-bottom: 0.5rem;
}

.calc-subtitle {
    font-size: 14px;
    color: var(--calc-text-muted);
    font-weight: 300;
}

/* ========== SECTIONS ========== */
.calc-section {
    background: var(--calc-surface);
    border: 1px solid var(--calc-border);
    border-radius: var(--calc-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--calc-text-muted);
    margin-bottom: 1.25rem;
}

/* ========== INPUT GROUPS ========== */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--calc-text);
    margin-bottom: 0.75rem;
}

.input-hint {
    font-size: 12px;
    font-weight: 300;
    color: var(--calc-text-muted);
}

.input-note {
    font-size: 12px;
    color: var(--calc-text-muted);
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* ========== PRESET BUTTONS ========== */
.preset-grid {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.preset-grid-4 {
    grid-template-columns: repeat(4, 1fr); /* 4-column grid */
}

.preset-btn {
    min-height: 50px; /* 44px + padding for thumb-friendly */
    padding: 0.75rem 0.5rem;
    border: 1px solid var(--calc-border);
    border-radius: 6px;
    background: var(--calc-bg);
    color: var(--calc-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--calc-accent);
    background: var(--calc-surface);
}

.preset-btn.active {
    border-color: var(--calc-accent);
    background: var(--calc-accent);
    color: #FFFFFF;
}

.preset-btn:active {
    transform: scale(0.98);
}

/* ========== TEXT INPUTS ========== */
.calc-input {
    width: 100%;
    min-height: 50px;
    padding: 0.875rem 1rem;
    border: 1px solid var(--calc-border);
    border-radius: 6px;
    background: var(--calc-bg);
    color: var(--calc-text);
    font-size: 16px; /* 16px prevents iOS zoom */
    font-family: inherit;
    transition: all 0.2s;
}

.calc-input:focus {
    outline: none;
    border-color: var(--calc-accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.calc-input::placeholder {
    color: var(--calc-text-muted);
    opacity: 0.6;
}

.calc-input.error {
    border-color: var(--calc-error);
}

/* ========== SYRINGE TYPE SELECTOR ========== */
.syringe-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.syringe-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--calc-border);
    border-radius: 6px;
    background: var(--calc-bg);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 50px;
}

.syringe-option:hover {
    border-color: var(--calc-accent);
    background: var(--calc-surface);
}

.syringe-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.syringe-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.syringe-text strong {
    font-size: 14px;
    color: var(--calc-text);
}

.syringe-text small {
    font-size: 12px;
    color: var(--calc-text-muted);
    font-weight: 300;
}

/* ========== ADVANCED SECTION ========== */
.advanced-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--calc-border);
}

.advanced-toggle {
    font-size: 14px;
    font-weight: 500;
    color: var(--calc-accent);
    cursor: pointer;
    list-style: none;
    padding: 0.75rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.advanced-toggle:hover {
    background: var(--calc-surface);
}

.advanced-toggle::marker {
    display: none;
}

.advanced-toggle::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s;
}

.advanced-section[open] .advanced-toggle::before {
    transform: rotate(90deg);
}

.advanced-content {
    padding-top: 1rem;
}

/* ========== RESULT SECTION ========== */
.result-section {
    background: var(--calc-accent);
    background: linear-gradient(135deg, var(--calc-accent) 0%, var(--calc-accent-hover) 100%);
    color: #FFFFFF;
    border: none;
}

.result-section .section-title {
    color: rgba(255, 255, 255, 0.9);
}

.result-container {
    text-align: center;
    padding: 1.5rem 0;
}

.result-primary {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.result-value {
    font-size: 48px;
    font-weight: 600;
    line-height: 1;
    animation: resultPop 0.3s ease-out;
}

@keyframes resultPop {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

.result-unit {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.95;
    padding-top: 12px;
}

.result-secondary {
    font-size: 14px;
    opacity: 0.8;
}

.copy-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.copy-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* ========== VERIFICATION ========== */
.verification {
    margin: 1.5rem 0;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.verification-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.verification-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.verification-content {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 13px;
}

.verification-step {
    padding: 0.25rem 0;
    font-family: 'Courier New', monospace;
    opacity: 0.95;
}

/* ========== RESULT METADATA ========== */
.result-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.meta-value {
    font-size: 16px;
    font-weight: 500;
}

/* ========== WARNINGS/ERRORS ========== */
.warning-message {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
}

.warning-message.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FFFFFF;
}

.warning-message.warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #FFFFFF;
}

.warning-message.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #FFFFFF;
}

.error-message {
    font-size: 12px;
    color: var(--calc-error);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* ========== DOSE GUIDE ========== */
.dose-guide {
    margin-top: 1.5rem;
}

.dose-guide-title {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    opacity: 0.9;
}

.dose-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dose-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 14px;
}

.dose-amount {
    font-weight: 500;
}

.dose-units {
    opacity: 0.9;
}

/* ========== ACTION BUTTONS ========== */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 50px;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #FFFFFF;
    color: var(--calc-accent);
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn:active {
    transform: scale(0.98);
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.empty-state-content p {
    color: var(--calc-text-muted);
    font-size: 14px;
}

.saved-empty {
    text-align: center;
    padding: 2rem;
    color: var(--calc-text-muted);
    font-size: 14px;
}

/* ========== SAVED PROTOCOLS ========== */
.saved-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.25rem;
}

.saved-hint {
    font-size: 11px;
    color: var(--calc-text-muted);
    font-weight: 300;
}

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.saved-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    background: var(--calc-bg);
    border: 1px solid var(--calc-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.saved-item:hover {
    border-color: var(--calc-accent);
    background: var(--calc-surface);
}

.saved-item-content {
    flex: 1;
}

.saved-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--calc-text);
    margin-bottom: 0.25rem;
}

.saved-item-details {
    font-size: 12px;
    color: var(--calc-text-muted);
}

.saved-item-notes {
    font-size: 12px;
    color: var(--calc-text-muted);
    margin-top: 0.25rem;
    font-style: italic;
}

.saved-item-delete {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--calc-text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.saved-item-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--calc-error);
}

/* ========== DISCLAIMER ========== */
.disclaimer {
    margin: 2rem 0;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
}

.disclaimer strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--calc-warning);
}

.disclaimer p {
    color: var(--calc-text-muted);
}

/* ========== MODALS ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] {
    display: none !important;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--calc-bg);
    border-radius: var(--calc-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--calc-border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--calc-text);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--calc-text-muted);
    font-size: 28px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--calc-surface);
    color: var(--calc-text);
}

.modal-body {
    padding: 1.5rem;
}

.modal-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--calc-text);
    margin-bottom: 0.5rem;
}

.modal-input,
.modal-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--calc-border);
    border-radius: 6px;
    background: var(--calc-bg);
    color: var(--calc-text);
    font-size: 16px;
    font-family: inherit;
    margin-bottom: 1rem;
}

.modal-input:focus,
.modal-textarea:focus {
    outline: none;
    border-color: var(--calc-accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.modal-textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--calc-border);
}

/* Help Modal Specific */
.help-section {
    margin-bottom: 1.5rem;
}

.help-section h4 {
    font-size: 16px;
    font-weight: 500;
    color: var(--calc-accent);
    margin-bottom: 0.75rem;
}

.help-section p,
.help-section li {
    font-size: 14px;
    color: var(--calc-text);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.help-section ol,
.help-section ul {
    padding-left: 1.5rem;
}

.help-section strong {
    color: var(--calc-accent);
}

/* ========== TOAST NOTIFICATION ========== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 1.5rem;
    background: var(--calc-text);
    color: #FFFFFF;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    z-index: 2000;
    animation: toastSlide 0.3s ease-out;
}

@keyframes toastSlide {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ========== RESPONSIVE - TABLET & DESKTOP ========== */

/* Tablet (768px+) */
@media (min-width: 768px) {
    .calc-container {
        padding: 2rem 1.5rem;
    }

    .calc-header h1 {
        font-size: 32px;
    }

    .preset-grid-4 {
        grid-template-columns: repeat(4, 1fr); /* Keep 4-column */
    }

    .syringe-group {
        flex-direction: row;
        gap: 0.75rem;
    }

    .syringe-option {
        flex: 1;
    }

    .saved-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .calc-container {
        max-width: 700px; /* Wider on desktop but still single-column */
        padding: 3rem 2rem;
    }

    .calc-nav {
        padding: 1rem 2rem;
    }

    .calc-section {
        padding: 2rem;
    }

    .preset-btn:hover {
        transform: translateY(-2px);
        box-shadow: var(--calc-shadow);
    }

    .result-section {
        position: sticky;
        top: 80px; /* Sticky on desktop for easy viewing while scrolling */
    }

    .saved-list {
        grid-template-columns: repeat(3, 1fr); /* 3-column on large desktop */
    }
}

/* ========== FOOTER ========== */
.calc-footer {
    padding: 2rem 1rem;
    text-align: center;
    border-top: 1px solid var(--calc-border);
    margin-top: 3rem;
}

.calc-footer .footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--calc-text-muted);
}

.calc-footer a {
    color: var(--calc-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.calc-footer a:hover {
    color: var(--calc-accent);
    text-decoration: underline;
}

.calc-footer span {
    color: var(--calc-text-muted);
    opacity: 0.5;
}

/* ========== ACCESSIBILITY ========== */
.calc-input:focus-visible,
.preset-btn:focus-visible,
.btn:focus-visible,
.syringe-option:focus-within {
    outline: 3px solid var(--calc-accent);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .preset-btn,
    .calc-input,
    .syringe-option {
        border-width: 2px;
    }
}

/* Reduced motion support */
@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 {
    .calc-nav,
    .action-buttons,
    .saved-list,
    .disclaimer {
        display: none;
    }

    .result-section {
        page-break-inside: avoid;
    }
}
