/* ================================
   REACIEN DESIGN SYSTEM v1.0
   Global Stylesheet
   ================================ */

/* FONTS */
@font-face {
    font-family: 'Martian Grotesk';
    font-display: swap;
    src: url('https://reacien.dev/static/fonts/MartianGrotesk-VF.woff2') format('woff2');
    font-weight: 100 1000;
    font-stretch: 75% 200%;
}

@font-face {
    font-family: 'Martian Mono';
    font-display: swap;
    src: url('https://reacien.dev/static/fonts/MartianMono-VF.woff2') format('woff2');
    font-weight: 100 800;
    font-stretch: 75% 112.5%;
}

/* ================================
     CSS VARIABLES (DESIGN TOKENS)
   ================================ */
:root {
    /* COLOR PALETTE */
    --bg-canvas: #fefcf8;
    --bg-panel: #ffc512;
    --bg-success: #00ff41;
    --ink-primary: #21201c;
    --ink-secondary: #5a5a55;
    --accent-system: #0070f3;
    --accent-alert: #ff2a3a;

    /* STRUCTURAL */
    --border-width: 3px;
    --border-hard: var(--border-width) solid var(--ink-primary);
    --shadow-depth: 6px;
    --shadow-hard: var(--shadow-depth) var(--shadow-depth) 0 var(--ink-primary);

    /* TYPOGRAPHY */
    --font-main: 'Martian Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --font-code: 'Martian Mono', 'Courier New', Consolas, monospace;

    /* SPACING */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
    --space-xl: 8rem;

    /* TRANSITIONS */
    --transition-smooth: 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    --transition-bounce: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --transition-fast: 0.15s ease-in-out;
}

/* ================================
      GLOBAL RESETS & BASE STYLES
   ================================ */
* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-main);
    background-color: var(--bg-canvas);
    background-image: radial-gradient(var(--ink-primary) 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--ink-primary);
    overflow: hidden;
}

/* ================================
            LAYOUT SYSTEM
   ================================ */
.page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-lg) var(--space-md);
}
.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Full-width container for standard pages */
.container-full {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* Centered content container */
.container-center {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* Left/Main Panel */
.panel-main {
    flex: 1;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: transparent;
    transition: flex var(--transition-smooth);
    position: relative;
    z-index: 2;
}

/* Right/Side Panel (Collapsible) */
.panel-side {
    flex-shrink: 0;
    width: 0;
    overflow-y: hidden;
    background: var(--bg-panel);
    border-left: 0;
    transition: width var(--transition-smooth);
    position: relative;
}

.panel-side.is-open {
    width: 600px;
    border-left: var(--border-hard);
    padding: var(--space-md);
    overflow-y: auto;
}

/* Content Wrappers */
.content-wrapper {
    background: var(--bg-canvas);
    padding: var(--space-md);
    border: var(--border-hard);
    box-shadow: var(--shadow-hard);
}

.card {
    background: white;
    border: var(--border-hard);
    box-shadow: var(--shadow-hard);
    padding: 3rem;
}

/* ================================
           UTILITY CLASSES
   ================================ */

/* Spacing Utilities */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }

.m-xs { margin: var(--space-xs); }
.mt-xs { margin-top: var(--space-xs); }
.mb-xs { margin-bottom: var(--space-xs); }
.ml-xs { margin-left: var(--space-xs); }
.mr-xs { margin-right: var(--space-xs); }

.m-sm { margin: var(--space-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mb-sm { margin-bottom: var(--space-sm); }
.ml-sm { margin-left: var(--space-sm); }
.mr-sm { margin-right: var(--space-sm); }

.m-md { margin: var(--space-md); }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.ml-md { margin-left: var(--space-md); }
.mr-md { margin-right: var(--space-md); }

.m-lg { margin: var(--space-lg); }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }
.ml-lg { margin-left: var(--space-lg); }
.mr-lg { margin-right: var(--space-lg); }

.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-auto { margin-top: auto; margin-bottom: auto; }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }
.pr-0 { padding-right: 0; }

.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* Display Utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Flexbox Utilities */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.align-stretch { align-items: stretch; }

.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Grid Utilities */
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Transform */
.text-uppercase { text-transform: uppercase; }
.text-lowercase { text-transform: lowercase; }
.text-capitalize { text-transform: capitalize; }

/* Font Weights */
.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* Font Sizes */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 2rem; }
.text-4xl { font-size: 3rem; }

/* Width Utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-50 { width: 50%; }
.w-25 { width: 25%; }
.w-75 { width: 75%; }

.max-w-xs { max-width: 20rem; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-full { max-width: 100%; }

/* Height Utilities */
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.h-auto { height: auto; }

/* Position Utilities */
.pos-relative { position: relative; }
.pos-absolute { position: absolute; }
.pos-fixed { position: fixed; }
.pos-sticky { position: sticky; }

/* Overflow Utilities */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Visibility */
.visible { visibility: visible; }
.invisible { visibility: hidden; }
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

/* Border Utilities */
.border-0 { border: none; }
.border { border: var(--border-hard); }
.border-top { border-top: var(--border-hard); }
.border-bottom { border-bottom: var(--border-hard); }
.border-left { border-left: var(--border-hard); }
.border-right { border-right: var(--border-hard); }

/* Shadow Utilities */
.shadow { box-shadow: var(--shadow-hard); }
.shadow-none { box-shadow: none; }

/* Background Colors */
.bg-canvas { background-color: var(--bg-canvas); }
.bg-panel { background-color: var(--bg-panel); }
.bg-success { background-color: var(--bg-success); }
.bg-white { background-color: white; }
.bg-black { background-color: black; }
.bg-transparent { background-color: transparent; }

/* Text Colors */
.text-primary { color: var(--ink-primary); }
.text-secondary { color: var(--ink-secondary); }
.text-white { color: white; }
.text-black { color: black; }
.text-success { color: var(--bg-success); }
.text-system { color: var(--accent-system); }
.text-alert { color: var(--accent-alert); }

/* Interactive States */
.hover-scale:hover { transform: scale(1.05); }
.hover-lift:hover { transform: translateY(-2px); }
.hover-shadow:hover { box-shadow: 8px 8px 0 var(--ink-primary); }

/* Transitions */
.transition { transition: all var(--transition-fast); }
.transition-smooth { transition: all var(--transition-smooth); }

/* ================================
              TYPOGRAPHY
   ================================ */
.font-main {
    font-family: var(--font-main);
}

.font-code {
    font-family: var(--font-code);
}

h1 {
    font-weight: 800;
    font-stretch: 125%;
    text-transform: uppercase;
    font-size: 3rem;
    margin: 0 0 1rem 0;
    line-height: 0.9;
}

h2 {
    font-weight: 700;
    font-size: 1.5rem;
    text-transform: uppercase;
    margin-top: 0;
}

h3 {
    font-weight: 700;
    font-size: 1.25rem;
    margin: 1rem 0;
}

h4 {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0.75rem 0;
}

p {
    font-size: 1.2rem;
    margin-bottom: var(--space-md);
    line-height: 1.6;
}

.subtitle {
    font-size: 1.1rem;
    margin-bottom: var(--space-md);
    border-left: 4px solid var(--accent-system);
    padding-left: 1rem;
}

.highlight {
    background: var(--accent-system);
    color: white;
    padding: 0 10px;
}

/* Lists */
ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

ul li, ol li {
    margin-bottom: 0.5rem;
}

.list-unstyled {
    list-style: none;
    padding-left: 0;
}

/* Links */
a {
    color: var(--accent-system);
    text-decoration: underline;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--ink-primary);
}

label {
    display: block;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: var(--space-xs);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

/* ================================
      BADGES & STATUS INDICATORS
   ================================ */
.badge {
    font-weight: 800;
    padding: 5px 10px;
    border: var(--border-hard);
    box-shadow: var(--shadow-hard);
    display: inline-block;
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: var(--bg-success);
    color: var(--ink-primary);
}

.badge-info {
    background: var(--accent-system);
    color: white;
}

.badge-alert {
    background: var(--accent-alert);
    color: white;
}

.badge-neutral {
    background: var(--bg-canvas);
    color: var(--ink-primary);
}

/* ================================
            FORM ELEMENTS
   ================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
textarea,
select {
    font-family: var(--font-code);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    font-weight: 500;
    width: 100%;
    padding: 1rem;
    background: white;
    border: var(--border-hard);
    outline: none;
    border-radius: 0;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    box-shadow: var(--shadow-hard);
    background: #fffef0;
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
}

/* Read-only inputs */
.input-readonly {
    flex: 1;
    background: #111;
    color: var(--bg-success);
    border: 2px solid #333;
    padding: 15px;
    font-size: 1rem;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================
              BUTTONS
   ================================ */
button,
.btn {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 100%;
    padding: 1.2rem;
    cursor: pointer;
    border: var(--border-hard);
    border-radius: 0;
    transition: all 0.1s;
    position: relative;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--bg-panel);
    color: var(--ink-primary);
    font-size: 1.4rem;
    box-shadow: var(--shadow-hard);
    margin-bottom: 1rem;
}

.btn-primary:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--ink-primary);
}

.btn-primary:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink-primary);
}

.btn-secondary {
    background: white;
    color: var(--ink-primary);
    box-shadow: var(--shadow-hard);
}

.btn-secondary:hover {
    background: var(--accent-system);
    color: white;
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--ink-primary);
}

.btn-secondary:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink-primary);
}

.btn-danger {
    background: var(--accent-alert);
    color: white;
    box-shadow: var(--shadow-hard);
}

.btn-danger:hover {
    background: #d61f1f;
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--ink-primary);
}

.btn-small {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
    display: block;
}

/* Small copy buttons */
.btn-copy {
    background: var(--bg-canvas);
    color: var(--ink-primary);
    border: var(--border-hard);
    padding: 0.3rem 0.8rem;
    font-weight: 700;
    font-size: 0.7rem;
    cursor: pointer;
    text-transform: uppercase;
    width: auto;
    min-width: 60px;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--bg-panel);
}

/* ================================
   CODE BLOCKS & TECHNICAL DISPLAYS
   ================================ */
.code {
    background: white;
    border: var(--border-hard);
    margin-bottom: var(--space-md);
    box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
}

.code-header {
    background: var(--ink-primary);
    color: var(--bg-canvas);
    padding: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1rem;
}

.code-body {
    padding: 1rem;
}

.code-body p {
    font-size: 1rem;
    margin: 0 0 1rem 0;
}

.code-block {
    background: #111;
    color: var(--bg-success);
    padding: 1rem;
    border: var(--border-hard);
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Inline code */
code {
    background: #f4f4f4;
    padding: 2px 6px;
    border: 1px solid var(--ink-primary);
    font-size: 0.9em;
}

pre {
    background: #111;
    color: var(--bg-success);
    padding: 1rem;
    border: var(--border-hard);
    overflow-x: auto;
}

/* URL Display Box */
.url-box {
    background: var(--ink-primary);
    border: var(--border-hard);
    padding: 1.5rem;
    margin-bottom: var(--space-md);
    text-align: left;
}

.url-label {
    color: white;
    font-size: 0.8rem;
    text-transform: uppercase;
    display: block;
    margin-bottom: var(--space-xs);
    opacity: 0.7;
}

.url-input-group {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-top: var(--space-xs);
}

/* ================================
          TOAST NOTIFICATIONS
   ================================ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-success);
    color: black;
    padding: 15px 30px;
    font-weight: 800;
    border: var(--border-hard);
    box-shadow: var(--shadow-hard);
    opacity: 0;
    transition: all var(--transition-bounce);
    z-index: 9999;
    text-transform: uppercase;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ================================
           SCROLLBAR STYLING
   ================================ */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #eee;
    border-left: 2px solid var(--ink-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-panel);
    border: 2px solid var(--ink-primary);
}

/* Panel-specific scrollbar */
.panel-side::-webkit-scrollbar-track {
    background: var(--ink-primary);
}

.panel-side::-webkit-scrollbar-thumb {
    background: white;
    border: 2px solid var(--ink-primary);
}

/* ================================
        GUIDE/STEPS COMPONENTS
   ================================ */
.guide-step {
    background: white;
    border: var(--border-hard);
    margin-bottom: var(--space-md);
    box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
}

.guide-step img {
    width: 100%;
    display: block;
    border-bottom: var(--border-hard);
    filter: grayscale(100%) contrast(110%);
}

.caption {
    padding: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    border-top: 1px dashed var(--ink-primary);
}

/* ================================
               TABLES
   ================================ */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: var(--border-hard);
    margin-bottom: var(--space-md);
}

thead {
    background: var(--ink-primary);
    color: var(--bg-canvas);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: var(--border-hard);
}

th {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.9rem;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-panel);
}

/* ================================
              DARK MODE
   ================================ */
body.dark-mode {
    --bg-canvas: #21201c;
    --ink-primary: #fefcf8;
    --border-hard: 3px solid #fefcf8;
    --shadow-hard: 6px 6px 0 #fefcf8;
}

body.dark-mode,
body.dark-mode html {
    background-image: radial-gradient(#444 1px, transparent 1px);
}

body.dark-mode .card,
body.dark-mode .content-wrapper,
body.dark-mode .code {
    background: #000;
    color: #fff;
}

body.dark-mode .badge-success {
    color: #000;
}

body.dark-mode .badge-neutral {
    background: #000;
    color: #fff;
}

body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode input[type="url"],
body.dark-mode textarea,
body.dark-mode select {
    background: #000;
    color: #fefcf8;
    border-color: #fefcf8;
}

body.dark-mode input[type="text"]:focus,
body.dark-mode input[type="email"]:focus,
body.dark-mode input[type="password"]:focus,
body.dark-mode input[type="number"]:focus,
body.dark-mode input[type="url"]:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
    background: #222;
}

body.dark-mode .input-readonly {
    border-color: #555;
}

body.dark-mode .token-label {
    color: black;
}

body.dark-mode .btn-primary {
    color: #000;
    border-color: #fff;
    box-shadow: 6px 6px 0 #fff;
}

body.dark-mode .btn-secondary {
    background: #000;
    color: #fff;
    border-color: #fff;
}

body.dark-mode .btn-copy {
    background: black;
    color: white;
}

body.dark-mode .code-header {
    background: #fff;
    color: #000;
}

body.dark-mode .caption {
    border-color: #fff;
}

body.dark-mode .guide-step img {
    filter: grayscale(100%) contrast(120%);
}

body.dark-mode code {
    background: #222;
    border-color: #fff;
}

body.dark-mode table {
    border-color: #fff;
}

body.dark-mode th,
body.dark-mode td {
    border-color: #fff;
}

body.dark-mode thead {
    background: #fff;
    color: #000;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #222;
    border-color: white;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--bg-panel);
    border-color: white;
}

/* ================================
   RESPONSIVE (MOBILE)
   ================================ */
@media (max-width: 1030px) {
    body, html {
        overflow-y: auto;
        height: auto;
        min-height: 100%;
    }

    .container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .panel-main {
        width: 100%;
        min-width: 0;
        min-height: auto;
        padding: var(--space-lg) var(--space-md);
        display: block;
    }

    .card {
        margin: 0 auto;
        max-width: 600px;
    }

    .panel-side {
        width: 100% !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.6s cubic-bezier(0.25, 1, 0.5, 1), padding 0.6s;
        padding: 0;
        height: auto;
    }

    .panel-side.is-open {
        max-height: 9999px;
        border-top: var(--border-hard);
        border-left: 0;
        padding: var(--space-md);
        overflow: visible;
    }

    h1 {
        font-size: 2.5rem;
    }

    /* Mobile-specific utilities */
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
}

/* Desktop-specific utilities */
@media (min-width: 1031px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
}