/* ============================================================
   CryptoInvest — Custom Stylesheet
   Complements Tailwind CDN with reusable component classes.
   ============================================================ */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* ---------- Typography ---------- */
.section-badge {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: rgba(99,102,241,0.1);
    color: #818cf8;
    margin-bottom: 0.5rem;
}
.section-title {
    font-size: 1.875rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 0.75rem;
    line-height: 1.15;
}
.section-sub {
    color: #94a3b8;
    max-width: 36rem;
    margin: 0 auto;
    line-height: 1.65;
}

/* ---------- Buttons ---------- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.1rem;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-weight: 600;
    border-radius: 0.75rem;
    transition: all 0.15s ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary:hover { background: linear-gradient(135deg,#818cf8,#6366f1); box-shadow: 0 8px 20px rgba(99,102,241,0.3); }

/* ---------- Form elements ---------- */
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
}
.form-input {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.625rem;
    color: #f1f5f9;
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.2s, color 0.2s;
    outline: none;
    color-scheme: dark;
}
.form-input::placeholder { color: #64748b; }
.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.form-input.border-red-500 { border-color: #ef4444; }
/* has-error: uses outline instead of border so it NEVER shifts the layout (outline is outside the box model) */
.form-input.has-error { outline: 2px solid #ef4444; outline-offset: 0; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1rem; padding-right: 2.5rem; }
.form-error { font-size: 0.72rem; color: #f87171; margin-top: 0.3rem; }
textarea.form-input { min-height: 80px; }

/* Prevent iOS Safari from auto-zooming on focus — any text input on
   small screens must render at >=16px regardless of utility overrides
   like `text-sm` applied alongside `.form-input`. */
@media (max-width: 640px) {
    input, select, textarea { font-size: 16px !important; }
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.badge-success  { background: rgba(16,185,129,0.12); color: #34d399; }
.badge-warning  { background: rgba(245,158,11,0.12); color: #fbbf24; }
.badge-danger   { background: rgba(239,68,68,0.12);  color: #f87171; }
.badge-info     { background: rgba(59,130,246,0.12); color: #60a5fa; }
.badge-secondary{ background: rgba(100,116,139,0.12);color: #94a3b8; }

/* ---------- Sidebar ---------- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.sidebar-link svg { color: #64748b; transition: color 0.15s ease; }
.sidebar-link:hover { background: #1e293b; color: #f1f5f9; }
.sidebar-link:hover svg { color: #a5b4fc; }
.sidebar-link:active { transform: scale(0.98); }
.sidebar-link.active { background: rgba(99,102,241,0.14); color: #c7d2fe; font-weight: 600; border-left-color: #6366f1; }
.sidebar-link.active svg { color: #818cf8; }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    border-radius: 0.625rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
}
.nav-link:hover { background: #1e293b; color: #f1f5f9; }

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #cbd5e1;
    border-radius: 0.625rem;
    border-left: 2px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    text-decoration: none;
}
.mobile-nav-link svg { color: #64748b; flex-shrink: 0; transition: color 0.15s ease; }
.mobile-nav-link:hover, .mobile-nav-link:active { background: #1e293b; color: #ffffff; border-left-color: #6366f1; }
.mobile-nav-link:hover svg, .mobile-nav-link:active svg { color: #a5b4fc; }

/* ---------- Crypto Ticker ---------- */
.ticker-wrapper { overflow: hidden; position: relative; }
.ticker-track {
    display: inline-flex;
    gap: 2rem;
    animation: tickerScroll 40s linear infinite;
    will-change: transform;
}
.ticker-track:hover { animation-play-state: paused; }
.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 500;
    color: #cbd5e1;
}
@media (max-width: 640px) {
    .ticker-item { font-size: 0.7rem; gap: 0.3rem; }
    .ticker-track { gap: 1.25rem; }
}
.ticker-item .symbol { color: #fff; font-weight: 700; }
.ticker-item .up   { color: #34d399; }
.ticker-item .down { color: #f87171; }

@keyframes tickerScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ---------- Flash messages ---------- */
.flash-msg { display: flex; align-items: center; gap: 0.75rem; animation: fadeDown 0.3s ease; }
@keyframes fadeDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ---------- Scrollbar (WebKit) ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #1e293b; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ---------- Transitions ---------- */
a, button { transition: all 0.15s ease; }

/* ── Mobile keyboard & touch improvements ─────────────────────────────────────
   touch-action: manipulation  → prevents the 300ms double-tap zoom on buttons
   and links that iOS/Android applies by default, which can cause the keyboard
   to dismiss unexpectedly when tapping "Submit" on forms.
   This does NOT interfere with scrolling or pinch-zoom.                      */
button, a, [role="button"], label[for],
input[type="submit"], input[type="button"], input[type="reset"] {
    touch-action: manipulation;
}

/* Prevent iOS from auto-styling text inputs as search fields */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], textarea, select {
    -webkit-appearance: none;
    appearance: none;
}

/* Ensure tap targets are comfortably large on mobile */
@media (max-width: 640px) {
    .form-input { min-height: 48px; }
    button[type="submit"] { min-height: 48px; }
}
