/*
 * Modern, minimal design for Base Converter
 * Uses Inter font, glass‑morphism card, and responsive layout.
 */

/* Reset & basics */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

	html, body {
	    height: 100%;
	    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	    /* Modern radial gradient background */
	    background: radial-gradient(circle at 20% 30%, #f0f4ff 0%, #e2e8f5 70%);
	    color: #212529;
	    /* Use normal block layout; top nav then content */
	    display: block;
	    -webkit-font-smoothing: antialiased;
	    -moz-osx-font-smoothing: grayscale;
	    overflow-x: hidden;
	}

/* Design tokens */
/* Design tokens for a fresh modern look */
:root {
    --card-bg: rgba(255, 255, 255, 0.90);
    --card-border: rgba(0, 0, 0, 0.07);
    --radius: 12px;
    --primary: #3b82f6;               /* Tailwind blue-500 */
    --primary-dark: #2563eb;           /* Tailwind blue-600 */
    --primary-hover: #60a5fa;          /* Tailwind blue-400 */
    --transition: 0.25s ease;
    --gap: 0.75rem;
}

/* Utility for screen‑reader only */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Card container */
/* Card container – wider to emulate translation services */
/* Card container – expanded to occupy most of the viewport */
/* Card container – modern translation‑site look */
/* Card styling – glassmorphism with subtle depth */
/* Card now occupies full width of its container */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--radius);
    /* Reduced padding for tighter layout */
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    overflow: auto;
    transition: var(--transition);
    /* Remove centering margin to allow full stretch */
    margin: 0;
}

/* Sidebar styling */
/* Sidebar – clean tutorial panel */
/* Sidebar – static part of the page (not overlay) */
/* Sidebar – ensure it expands to full page height even when main content overflows */
/* Sidebar – ensure it expands to full page height even when main content overflows */
/* Sidebar – full‑height beside the main content */
/* Sidebar – full‑height beside the main content */
 .sidebar {
    /* Stretch to match the height of the content column */
    width: 280px;
    flex: 0 0 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--card-border);
    padding: 1.5rem 1rem 1.5rem 1.5rem;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
    box-shadow: 2px 0 6px rgba(0,0,0,0.08);
}

/* Top navigation bar */
.top-nav {
    background: var(--primary);
    color: #fff;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 20;
}

.top-nav .nav-title {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Container that holds the sidebar and main content side‑by‑side */
.content {
    display: flex;
    flex: 1 1 0;
    min-height: 0; /* allow children to shrink correctly */
}

/* Hidden state – move off‑screen */
/* Hidden state – slide off‑screen */
.sidebar.closed {
    /* Hide the sidebar completely when closed */
    display: none;
}

/* When sidebar is hidden, expand the main container */
/* When sidebar is hidden, let the main container grow to fill the space */
.sidebar.closed + .container {
    flex: 1 1 100%;
}

/* Open/close buttons */
/* Small hamburger button for narrow screens */
.sidebar-open {
    position: fixed;
    top: 1rem;
    left: 0;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 0 4px 4px 0;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    z-index: 11;
    display: none; /* toggled via media query */
    box-shadow: 1px 1px 4px rgba(0,0,0,0.1);
}

/* Close (X) button inside the sidebar */
.sidebar-close {
    background: transparent;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 1.2rem;
    float: right;
    margin-top: -0.2rem;
}

/* Adjust main container when sidebar is visible */
/* Main content shifts when sidebar is visible */
/* Main content container – shifted when sidebar is visible without causing overflow */
/* Main content container – occupies remaining viewport when sidebar is shown */
/* Main content container – occupies remaining space */
/* Removed previous container shifting logic – sidebar now overlays without pushing content */

/* Show open button on narrow screens */
@media (max-width: 800px) {
    /* Hide sidebar on small screens – it will be toggled via the open button */
    .sidebar {
        display: none;
    }
    .sidebar-open {
        display: block;
    }
    /* Expand container to full width when sidebar is hidden */
    .container {
        /* When sidebar hidden, container simply takes full width as flex child */
        flex: 1 1 100%;
    }
}

/* Typography inside sidebar */
.sidebar h2 {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.sidebar h3 {
    font-size: 1.2rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
    font-weight: 500;
}

.sidebar p {
    margin-bottom: 0.75rem;
    line-height: 1.5;
    color: #212529;
}

.sidebar pre {
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Styling for conversion‑step section */
/* Conversion steps box – match padding of the main converter card */
.steps {
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    /* Tutorial‑log feel */
    border-left: 4px solid var(--primary);
    background: #fafafa;
}

/* Basic typography for the steps pane */
/* General paragraph spacing inside steps */
.steps p {
    margin: 0.4rem 0;
}
/* Specific spacing for the note paragraph to add extra whitespace below */
.steps .steps-note {
    margin-bottom: 1rem;
}

.steps ul {
    margin: 0.4rem 0 0.4rem 1.5rem;
    padding-left: 0;
    list-style-type: disc;
}

.steps li {
    margin: 0.2rem 0;
}

.steps strong {
    color: var(--primary-dark);
}

.steps code {
    background: #e9ecef;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* Note below the steps heading */
.steps-note {
    font-size: 0.9rem;
    color: #555;
    margin: 0.4rem 0 1rem 0; /* extra space below the note */
    line-height: 1.4;
}

/* Icon next to the steps note */
.steps-note .steps-note-icon {
    font-size: 1rem;
    vertical-align: middle;
    margin-right: 0.3rem;
    color: var(--primary);
}

/* Visual hint for padded zeros in binary output */
.pad-zero {
    color: #999; /* lighter gray */
    opacity: 0.7;
}

/* Navigation and step‑by‑step styles removed – now showing all steps at once */
.container {
    /* Prevent the container from consuming all vertical space so the steps remain visible */
    flex: 0 0 auto; /* size to content height */
    min-width: 0; /* prevent overflow from flex children */
    margin: 0; /* keep no extra margin */
    width: 100%; /* fill available width within main-wrapper */
    max-width: none; /* ensure no max‑width restriction */
    box-sizing: border-box;
    transition: flex var(--transition);
}

/* Wrapper that holds the main container and the steps section vertically */
/* Wrapper that holds the main container and the steps section vertically */
.main-wrapper {
    /* Holds the primary converter card and the steps pane */
    display: flex;
    flex-direction: column;
    gap: 1rem;               /* reduced spacing */
    flex: 1 1 0;               /* occupy remaining width next to sidebar */
    min-width: 0;
    width: 100vw;           /* span full viewport width */
    padding: 1rem;           /* internal padding */
}


h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-size: 1.75rem;
    color: #212529;
}

/* Layout */
/* Converter layout – allow wrapping on narrow widths */
/* Converter layout – original two‑panel layout */
.converter {
    display: flex;
    align-items: stretch;
    gap: 1.5rem;
    flex-direction: row;
    flex-wrap: nowrap;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

select,
textarea {
    width: 100%;
    /* Larger touch targets */
    padding: 0.8rem 1rem;
    font-size: 1.1rem;
    border: 1px solid #ced4da;
    border-radius: var(--radius);
    color: #212529;
    font-family: inherit;
    appearance: none;
    transition: var(--transition);
    /* Prevent textarea resizing */
    resize: none;
}

/* Larger font for textarea content */
textarea {
    font-size: 1.4rem;
}
/* Dropdowns stay white */
select {
    background: #fff;
}
/* Textareas keep the gray background */
textarea {
    background: #f8f9fa;
}

/* Focus styling – no outline, only border color change */
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Ensure disabled inputs and textareas never show an outline */
select:disabled,
textarea:disabled {
    outline: none;
    cursor: not-allowed;
    opacity: 0.6;
    background: #e9ecef;
    color: #6c757d;
    border-color: #ced4da;
}

textarea[readonly] {
    background: #e9ecef;
    color: #495057;
}

/* Swap button */
#swapBtn {
    align-self: center;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px; /* modern rounded square */
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform 0.3s ease;
    will-change: background, transform;
}

/* Material icon inside swap button */
#swapBtn .material-icons,
#swapBtn .material-icons-round {
    font-size: 1.5rem;
    line-height: 1;
    display: block; /* ensure flex centering works */
}

#swapBtn:hover {
    background: var(--primary-hover);
    transform: scale(1.08);
}

/* Copy button – smaller square, placed beside inputs/outputs */
/* Copy button positioned inside input/output containers */
.input-wrapper, .output-wrapper {
    position: relative;
}

/* Slightly larger offset for better spacing */
/* Clipboard button – smaller icon with padded hover background */
/* Clipboard button – more rounded rectangle */
.copyBtn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: transparent;
    color: #6c757d; /* subtle gray */
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Add internal padding so hover background is larger */
    padding: 4px;
    transition: color var(--transition), background var(--transition);
}

.copyBtn:hover {
    background: rgba(0,0,0,0.08);
    color: #495057;
}

/* Swap wrapper – centers the button between panels */
/* Swap button wrapper – full‑width when panels wrap */
/* Swap wrapper – keep centered without expanding */
.swap-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Make textareas fill the available vertical space */
.panel textarea {
    /* Larger textareas */
    flex-grow: 1;
    min-height: 250px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Highlighted output mimics textarea styling */
.highlight {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1.4rem;
    border: 1px solid #ced4da;
    border-radius: var(--radius);
    background: #fff;
    color: #212529;
    font-family: inherit;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    min-height: 250px;
    max-height: 70vh;
    box-sizing: border-box;
}

/* Simple cyclic colour scheme for characters */
/* Colour classes for characters – same character gets same colour */
/* Character colour classes – scoped to .highlight spans */
.highlight span.c0 { color: #d32f2f; }
.highlight span.c1 { color: #1976d2; }
.highlight span.c2 { color: #388e3c; }
.highlight span.c3 { color: #f57c00; }
.highlight span.pad-zero { color: #999 !important; opacity: 0.7; }
.steps .pad-zero { color: #999 !important; opacity: 0.7; }

/* Responsive adjustments */
@media (max-width: 600px) {
    .card {
        padding: 1.5rem;
    }
    .converter {
        flex-direction: column;
        align-items: stretch;
    }
    .panel {
        min-width: 100%;
    }
    #swapBtn {
        margin: 0.5rem 0;
    }
}
