/* Trade Spinners — custom styles + layout fixes */

/* Fix horizontal scroll */
html,
body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

/* Ensure all elements respect width (can constrain wide flex children) */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    max-width: 100%;
}

/* Ensure containers don't spill past viewport */
.container,
.max-w-7xl,
.max-w-md,
.max-w-lg,
.max-w-xl,
.max-w-2xl,
.max-w-3xl,
.max-w-4xl,
.max-w-5xl,
.max-w-6xl {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Media stays within layout */
img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

/* Tables / wide content: scroll inside, not page */
.overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

[x-cloak] {
    display: none !important;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

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

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

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.flash-message {
    transition: all 0.3s ease;
}

.field-error {
    display: none;
}

.field-error.visible {
    display: block;
}

.loading-spinner {
    display: none;
}

.loading .loading-spinner {
    display: inline-block;
}

.loading .normal-text {
    display: none;
}

/* --------------------------------------------------------------------------
   Dark theme — tokens + component overrides (used with [data-theme="dark"] on html)
   -------------------------------------------------------------------------- */

[data-theme="dark"],
.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

/* Form inputs */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: #6366f1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.35);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #64748b;
}

/* Tables */
[data-theme="dark"] table {
    background-color: #1e293b;
}

[data-theme="dark"] thead {
    background-color: #0f172a;
}

[data-theme="dark"] tbody tr {
    border-color: #334155;
}

[data-theme="dark"] tbody tr:hover {
    background-color: #334155;
}

/* Cards / surfaces (Tailwind utility classes) */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-slate-50,
[data-theme="dark"] .bg-gray-50 {
    background-color: #1e293b !important;
}

/* Modal / dropdown helpers (use these class names on components) */
[data-theme="dark"] .modal-content {
    background-color: #1e293b;
}

[data-theme="dark"] .dropdown-menu {
    background-color: #1e293b;
    border-color: #334155;
}

/* Status badges */
[data-theme="dark"] .bg-green-100 {
    background-color: #14532d !important;
    color: #86efac !important;
}

[data-theme="dark"] .bg-yellow-100 {
    background-color: #713f12 !important;
    color: #fde047 !important;
}

[data-theme="dark"] .bg-red-100 {
    background-color: #991b1b !important;
    color: #fecaca !important;
}

[data-theme="dark"] .bg-slate-100 {
    background-color: #334155 !important;
    color: #cbd5e1 !important;
}

/* Flash messages */
[data-theme="dark"] .bg-green-50 {
    background-color: #14532d !important;
    border-color: #166534 !important;
    color: #86efac !important;
}

[data-theme="dark"] .bg-red-50 {
    background-color: #991b1b !important;
    border-color: #7f1a1a !important;
    color: #fecaca !important;
}

[data-theme="dark"] .bg-yellow-50 {
    background-color: #713f12 !important;
    border-color: #854d0e !important;
    color: #fde047 !important;
}

/* Scrollbars (WebKit) */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1e293b;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* --------------------------------------------------------------------------
   Dark mode — Tailwind utility contrast (class on html or body)
   -------------------------------------------------------------------------- */

:is(.dark, [data-theme="dark"]) body {
    color: #f1f5f9 !important;
}

:is(.dark, [data-theme="dark"]) .text-slate-600,
:is(.dark, [data-theme="dark"]) .text-gray-600 {
    color: #cbd5e1 !important;
}

:is(.dark, [data-theme="dark"]) .text-slate-500,
:is(.dark, [data-theme="dark"]) .text-gray-500 {
    color: #94a3b8 !important;
}

:is(.dark, [data-theme="dark"]) .text-slate-700,
:is(.dark, [data-theme="dark"]) .text-gray-700 {
    color: #e2e8f0 !important;
}

:is(.dark, [data-theme="dark"]) .text-slate-800,
:is(.dark, [data-theme="dark"]) .text-gray-800 {
    color: #f1f5f9 !important;
}

:is(.dark, [data-theme="dark"]) label,
:is(.dark, [data-theme="dark"]) .field-label {
    color: #e2e8f0;
}

:is(.dark, [data-theme="dark"]) code {
    background-color: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
}

:is(.dark, [data-theme="dark"]) td,
:is(.dark, [data-theme="dark"]) th {
    color: #e2e8f0;
}

:is(.dark, [data-theme="dark"]) .bg-white,
:is(.dark, [data-theme="dark"]) .bg-slate-50,
:is(.dark, [data-theme="dark"]) .bg-gray-50 {
    background-color: #1e293b !important;
}

/* Crypto subscription checkout: wallet address legible on gradient hero + dark theme */
.crypto-wallet-address-box {
    word-break: break-word;
}

:is(.dark, [data-theme="dark"]) .crypto-wallet-address-box {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}
