/* ResellMode v3.0 - Shared Styles */
/* Light mode default, dark mode when .light-mode class is removed */

/* ========== Cross-Browser Compatibility ========== */
/* Safari/iOS smooth scrolling */
html {
    -webkit-overflow-scrolling: touch;
}

/* Gap fallback for iOS Safari < 14.1 (uses margin on children) */
@supports not (gap: 1px) {
    .site-header > *:not(:last-child),
    .header-actions > *:not(:last-child),
    .input-group > *:not(:last-child),
    .button-row > *:not(:last-child),
    .footer-links > *:not(:last-child) {
        margin-right: 8px;
        margin-bottom: 8px;
    }
}

/* Prevent tap highlight on iOS */
* {
    -webkit-tap-highlight-color: transparent;
}

/* 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;
        scroll-behavior: auto !important;
    }
}

/* ========== CSS Variables ========== */
:root {
    /* Light Mode (Default) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-input: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-focus: #22c55e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --green: #22c55e;
    --green-light: #dcfce7;
    --green-dark: #166534;
    --red: #ef4444;
    --red-light: #fee2e2;
    --blue: #3b82f6;
    --blue-light: #dbeafe;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --orange: #f59e0b;
    --orange-light: #fef3c7;
    --pink: #ec4899;
    --pink-light: #fce7f3;
}

:root:not(.light-mode), :root[data-theme="dark"] {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-tertiary: #242d3d;
    --bg-input: #1a1f2e;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #2d3748;
    --border-focus: #22c55e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --green-light: #166534;
    --red-light: #7f1d1d;
    --blue-light: #1e3a8a;
    --purple-light: #4c1d95;
    --orange-light: #78350f;
    --pink-light: #831843;
}

/* ========== Base Reset ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { 
    scroll-behavior: smooth;
    overscroll-behavior: none; /* Prevent rubber-band bounce */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari fix */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-transition: background 0.2s, color 0.2s;
    transition: background 0.2s, color 0.2s;
    padding: 20px;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    /* Prevent font size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior: none; /* Prevent rubber-band bounce */
}

/* iOS input zoom prevention */
input, select, textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Touch-friendly tap targets */
button, .btn, a.btn, .back-btn, .theme-toggle, .preset-btn {
    min-height: 44px; /* Apple HIG minimum */
    min-width: 44px;
}

/* ========== Layout ========== */
.container {
    max-width: 700px;
    margin: 0 auto;
}

.container.wide {
    max-width: 900px;
}

.container.narrow {
    max-width: 500px;
}

/* ========== Header ========== */
.site-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

/* Brand logo for inner pages */
.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: all 0.15s;
    flex-shrink: 0;
}
.header-brand:hover {
    border-color: var(--green);
    background: var(--green-light);
}
.header-brand svg {
    width: 20px;
    height: 20px;
}
.header-brand span {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--green);
    display: none;
}
@media (min-width: 500px) {
    .header-brand span {
        display: inline;
    }
}

.back-btn {
    width: 48px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
    padding-left: 6px;
}

/* Arrow indicator on left side */
.back-btn::before {
    content: '‹';
    position: absolute;
    left: 6px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
}

/* Move logo SVG slightly right to make room for arrow */
.back-btn svg {
    margin-left: 4px;
}

@media (hover: hover) {
    .back-btn:hover {
        border-color: var(--green);
        background: var(--green-light);
    }
}

.back-btn:active {
    transform: scale(0.95);
}

.page-title {
    flex: 1;
    min-width: 0;
}

.page-title h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-title .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--green-light);
    color: var(--green);
    border-radius: 20px;
    font-weight: 600;
}

:root:not(.light-mode), :root[data-theme="dark"] .page-title .badge {
    background: var(--green-dark);
    color: var(--green);
}

.page-title .subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.15s;
    color: var(--text-secondary);
}

.icon-btn:hover {
    border-color: var(--green);
    background: var(--green-light);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ========== Cards & Panels ========== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== Form Elements ========== */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.large {
    font-size: 1.5rem;
    padding: 15px;
    font-weight: 600;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--green);
    color: white;
    will-change: transform;
}

@media (hover: hover) {
    .btn-primary:hover {
        background: #1da34d;
        transform: scale(1.02);
    }
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-outline {
    background: transparent;
    color: var(--green);
    border: 1px solid var(--green);
}

.btn-outline:hover {
    background: var(--green-light);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 28px;
    font-size: 1.1rem;
}

/* ========== Results Display ========== */
.result-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin: 15px 0;
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--green);
}

.result-value.negative {
    color: var(--red);
}

.result-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* ========== Tables ========== */
.table-wrapper {
    overflow-x: auto;
    margin: 15px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    color: var(--text-primary);
}

tr:hover td {
    background: var(--bg-tertiary);
}

/* ========== Lists ========== */
.list-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 8px;
    gap: 12px;
    transition: all 0.15s;
    text-decoration: none;
    color: inherit;
}

.list-item:hover {
    border-color: var(--green);
    transform: translateX(3px);
}

.list-item .icon {
    font-size: 1.3rem;
    width: 40px;
    text-align: center;
}

.list-item .info {
    flex: 1;
}

.list-item .title {
    font-weight: 600;
    color: var(--text-primary);
}

.list-item .desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.list-item .arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* ========== Content Typography ========== */
.content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 25px 0 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--green);
}

.content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 10px;
}

.content p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.content ul, .content ol {
    margin: 15px 0;
    padding-left: 25px;
}

.content li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.content a {
    color: var(--green);
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

.content blockquote {
    border-left: 4px solid var(--green);
    padding-left: 15px;
    margin: 15px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.content pre {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
}

.content pre code {
    background: none;
    padding: 0;
}

/* ========== Alerts & Messages ========== */
.alert {
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: var(--green-light);
    border: 1px solid var(--green);
    color: var(--green-dark);
}

.alert-error {
    background: var(--red-light);
    border: 1px solid var(--red);
    color: #991b1b;
}

.alert-info {
    background: var(--blue-light);
    border: 1px solid var(--blue);
    color: #1e40af;
}

.alert-warning {
    background: var(--orange-light);
    border: 1px solid var(--orange);
    color: #92400e;
}

:root:not(.light-mode), :root[data-theme="dark"] .alert-success { color: #86efac; }
:root:not(.light-mode), :root[data-theme="dark"] .alert-error { color: #fca5a5; }
:root:not(.light-mode), :root[data-theme="dark"] .alert-info { color: #93c5fd; }
:root:not(.light-mode), :root[data-theme="dark"] .alert-warning { color: #fcd34d; }

/* ========== Footer ========== */
.site-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--green);
}

.footer-disclosure {
    background: var(--bg-tertiary);
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    line-height: 1.5;
}

.footer-disclaimer {
    background: var(--bg-tertiary);
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
    border-left: 3px solid var(--orange);
}

.footer-disclaimer a {
    color: var(--text-secondary);
}

.footer-copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== Affiliate Links - REVENUE GENERATOR ========== */
.aff-container {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    border: 2px solid var(--green);
    border-radius: 14px;
    padding: 18px 22px;
    margin: 25px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.15);
}

.aff-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    padding: 12px 24px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.3);
    transition: all 0.25s ease;
    will-change: transform, box-shadow;
}

/* Hover only on devices that support it */
@media (hover: hover) {
    .aff-link:hover {
        transform: scale(1.02);
        box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
        background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    }
}

/* Active state for mobile taps */
.aff-link:active {
    transform: scale(0.98);
    background: linear-gradient(135deg, #16a34a 0%, #14532d 100%);
}

/* Light mode disclosure - visible green text */
.aff-disclosure {
    font-size: 0.7rem;
    color: #166534;
    flex-basis: 100%;
    text-align: center;
    margin-top: 5px;
}

/* Dark mode affiliate */
:root:not(.light-mode), :root[data-theme="dark"] .aff-container {
    background: linear-gradient(135deg, #14532d 0%, #166534 100%);
}

:root:not(.light-mode), :root[data-theme="dark"] .aff-disclosure {
    color: #bbf7d0;
}

/* ========== Utility Classes ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.hidden { display: none !important; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

/* ========== Responsive ========== */
@media (max-width: 500px) {
    body { padding: 15px; }
    .site-header { gap: 10px; }
    .page-title h1 { font-size: 1.2rem; }
    .card { padding: 15px; }
    .result-value { font-size: 1.6rem; }
    .footer-links { gap: 15px; }
}

/* ========== Print Styles ========== */
@media print {
    body { background: white; color: black; }
    .site-header, .site-footer { display: none; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
