/* ============================================
   Position Size Calculator Styles
   Dark theme matching article.css design system
   ============================================ */

/* ============================================
   CSS Custom Properties (Calculator-specific)
   ============================================ */

.calculator-page {
    --surface-primary: #161a1f;
    --surface-secondary: #1e252f;
    --border-color: #404245;
    --text-primary: #f7fff7;
    --text-secondary: #888;
    --text-tertiary: #666;
    --accent: #ff6b6b;
    --green: #22c55e;
    --red: #ef4444;
    --blue: #3b82f6;
}

/* ============================================
   Calculator Grid - 2-column layout
   ============================================ */

.calculator-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 16px;
    margin-top: 24px;
}

@media (max-width: 1023px) {
    .calculator-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 767px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Panel - Input/Output containers
   ============================================ */

.panel {
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
}

/* ============================================
   Live Price Badge
   ============================================ */

.live-price-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    width: fit-content;
    flex-wrap: wrap;
}

.live-price-badge.offline .live-dot {
    background: #6b7280;
    animation: none;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-calc 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-calc {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

.price-label {
    font-weight: 600;
    color: var(--text-primary);
}

.price-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
}

.live-price-badge .price-change {
    font-size: 13px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.live-price-badge .price-change.positive {
    color: var(--green);
}

.live-price-badge .price-change.negative {
    color: var(--red);
}

.price-timestamp {
    font-size: 11px;
    color: var(--text-tertiary);
}

.use-price-btn {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.use-price-btn:hover {
    background: var(--surface-primary);
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================
   Input Fields
   ============================================ */

.field-group {
    margin-bottom: 12px;
}

.field-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.field-header label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.field-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.pct-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.pct-badge.positive {
    color: var(--green);
    background: rgba(34, 197, 94, 0.1);
}

.pct-badge.negative {
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}

.calculator-page input[type="number"],
.calculator-page select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface-primary);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.calculator-page input[type="number"]:focus,
.calculator-page select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15);
}

.calculator-page input[type="number"]::placeholder {
    color: #555;
}

/* Hide number spinner */
.calculator-page input[type="number"]::-webkit-outer-spin-button,
.calculator-page input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.calculator-page input[type="number"] {
    -moz-appearance: textfield;
}

/* Select dropdown styling */
.calculator-page select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

.calculator-page select option {
    background: var(--surface-primary);
    color: var(--text-primary);
}

/* Range Slider */
.calculator-page input[type="range"] {
    width: 100%;
    margin-top: 6px;
    accent-color: var(--accent);
    cursor: pointer;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Risk percentage display */
.risk-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.risk-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', monospace;
    min-width: 40px;
}

/* ============================================
   Metrics Grid - 2x2 result cards
   ============================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric-card {
    background: var(--surface-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    container-type: inline-size;
}

.metric-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.metric-value {
    font-size: clamp(14px, 4.5cqi, 22px);
    font-weight: 500;
    margin-top: 2px;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    white-space: nowrap;
}

.metric-value.danger {
    color: var(--red);
}

.metric-value.success {
    color: var(--green);
}

/* ============================================
   R:R Ratio Section
   ============================================ */

.rr-section {
    margin-top: 16px;
}

.rr-numbers {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.rr-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', monospace;
}

.rr-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bew-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', monospace;
}

.rr-bar-track {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    gap: 2px;
    margin-top: 8px;
}

.rr-bar-risk {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    transition: width 0.3s ease;
    min-width: 36px;
    border-radius: 6px 0 0 6px;
}

.rr-bar-reward {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    transition: width 0.3s ease;
    min-width: 36px;
    border-radius: 0 6px 6px 0;
}

/* ============================================
   EV Box
   ============================================ */

.ev-box {
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    margin-top: 10px;
    background: var(--surface-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.ev-box.ev-box--positive {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.ev-box.ev-box--negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ev-box.ev-box--neutral {
    background: var(--surface-secondary);
    color: var(--text-secondary);
}

/* ============================================
   Price Ladder (SVG)
   ============================================ */

.ladder-wrap {
    margin-top: 16px;
    background: var(--surface-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    overflow: hidden;
}

.ladder-wrap svg {
    display: block;
    width: 100%;
    height: auto;
}

/* ============================================
   Related Pairs Grid
   ============================================ */

.related-pairs {
    margin-top: 40px;
}

.related-pairs h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.related-pairs-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pair-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.pair-link:hover {
    border-color: var(--accent);
    background: var(--surface-secondary);
    text-decoration: none;
    color: var(--text-primary);
}

.pair-link .pair-link-arrow {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* ============================================
   SEO Content Block
   ============================================ */

.seo-content {
    margin-top: 56px;
}

.seo-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 32px 0 12px;
    color: var(--text-primary);
}

.seo-content p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ============================================
   Calculator Pairs Grid (Index page)
   ============================================ */

.calculator-pairs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .calculator-pairs-grid {
        grid-template-columns: 1fr;
    }
}

.calculator-pair-card {
    display: block;
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.calculator-pair-card:hover {
    background: rgba(255, 107, 107, 0.08);
    border-color: rgba(255, 107, 107, 0.3);
    text-decoration: none;
    transform: translateY(-2px);
}

.calculator-pair-card .pair-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.calculator-pair-card .pair-assets {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calculator-pair-card .from-asset {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.calculator-pair-card .pair-assets i {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.calculator-pair-card .to-asset {
    font-size: 1rem;
    font-weight: 600;
    color: #44a4cd;
}

.calculator-pair-card .pair-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.calculator-pair-card .pair-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.calculator-pair-card .pair-rate {
    font-size: 0.85rem;
    color: #ced4da;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.calculator-pair-card .pair-change {
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.calculator-pair-card .pair-change.positive {
    color: var(--green);
    background: rgba(34, 197, 94, 0.1);
}

.calculator-pair-card .pair-change.negative {
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}

/* Skeleton loading for index cards */
.calculator-pair-card .pair-rate.skeleton,
.calculator-pair-card .pair-change.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05) !important;
    color: transparent !important;
    border-radius: 4px;
}

.calculator-pair-card .pair-rate.skeleton::after,
.calculator-pair-card .pair-change.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    animation: skeleton-shimmer-calc 1.5s infinite;
}

@keyframes skeleton-shimmer-calc {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.calculator-pair-card .pair-rate.skeleton {
    min-width: 120px;
    height: 1.2em;
    display: inline-block;
}

.calculator-pair-card .pair-change.skeleton {
    min-width: 60px;
}

/* Price update animation */
.calculator-pair-card .pair-rate.updated,
.calculator-pair-card .pair-change.updated {
    animation: price-flash-calc 0.3s ease;
}

@keyframes price-flash-calc {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ============================================
   Index Hero Section
   ============================================ */

.calculator-hero .summary-box {
    border-left: 4px solid var(--accent);
}

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

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

/* Focus-visible for keyboard nav */
.calculator-page input:focus-visible,
.calculator-page select:focus-visible,
.calculator-page button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   Responsive adjustments
   ============================================ */

@media (max-width: 767px) {
    .live-price-badge {
        width: 100%;
        font-size: 13px;
        gap: 8px;
    }

    .metric-value {
        font-size: 16px;
    }

    .rr-value,
    .bew-value {
        font-size: 16px;
    }

    .panel {
        padding: 14px 16px;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .rr-numbers {
        gap: 10px;
    }

    .live-price-badge {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

/* ─── Search / Filter ───────────────────────────────────── */
.pairs-filter {
    margin-bottom: 1.5rem;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper i {
    position: absolute;
    left: 1rem;
    color: #888;
    font-size: 0.9rem;
}

.pairs-search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    background: #161a1f;
    border: 2px solid #404245;
    border-radius: 10px;
    color: #f7fff7;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pairs-search-input::placeholder {
    color: #666;
}

.pairs-search-input:focus {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15);
}

.no-results-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

.no-results-message i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results-message p {
    font-size: 1rem;
    margin: 0;
}

/* ─── Automation CTA Banner ─────────────────────────────── */
.automation-cta-banner {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    background: linear-gradient(135deg, #1e252f 0%, #252d38 100%);
    border: 1px solid #3a3d42;
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    position: relative;
    overflow: hidden;
}

.automation-cta-banner::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #ff6b6b 0%, #ff8e53 100%);
}

.automation-cta-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    margin-top: 0.125rem;
}

.automation-cta-content {
    flex: 1;
    min-width: 0;
}

.automation-cta-title {
    color: #f7fff7;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 0.375rem 0;
}

.automation-cta-desc {
    color: #9ca3af;
    font-size: 0.9rem;
    line-height: 1.45;
    margin: 0 0 1rem 0;
}

.automation-cta-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.automation-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    background: #ff6b6b;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.automation-btn-primary:hover {
    background: #ff5252;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.automation-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    background: transparent;
    color: #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #4a4d52;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.automation-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #666;
    color: #fff;
    text-decoration: none;
}

@media (max-width: 576px) {
    .automation-cta-banner {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1.5rem;
    }

    .automation-cta-icon {
        margin-top: 0;
    }

    .automation-cta-buttons {
        justify-content: center;
        width: 100%;
    }

    .automation-btn-primary,
    .automation-btn-secondary {
        flex: 1;
        min-width: 140px;
    }
}
