/**
 * Local Conversion Hub - Main Stylesheet
 * Responsive, modern, and performance-optimized
 */

/* CSS Variables */
:root {
    --primary-color: #0066cc;
    --primary-dark: #0052a3;
    --bg-light: #f8f9fa;
    --bg-lighter: #f0f0f0;
    --border-color: #e0e0e0;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #2a2a2a;
        --bg-lighter: #333;
        --border-color: #444;
        --text-primary: #e0e0e0;
        --text-secondary: #999;
        --text-light: #666;
    }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: #fff;
    transition: background-color 0.3s, color 0.3s;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #1a1a1a;
        color: var(--text-primary);
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.2rem;
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

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

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Main Layout */
main {
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

/* Header Styles */
header {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

header .logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    white-space: nowrap;
}

header nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    flex: 1;
}

header nav a {
    color: inherit;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s;
}

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

.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 200px;
    background: #fff;
    color: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
    .search-box input {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
}

/* Responsive Header */
@media (max-width: 768px) {
    header nav {
        flex-direction: column;
        gap: 1rem;
    }

    header nav ul {
        gap: 1rem;
        font-size: 0.85rem;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        min-width: 100%;
    }
}

/* Form Elements */
input[type="text"],
input[type="number"],
select,
textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.3s;
}

@media (prefers-color-scheme: dark) {
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

button {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

/* Accessibility */
button:focus,
a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Hit targets */
button,
a[role="button"],
input[type="checkbox"],
input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

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

th {
    background: var(--bg-light);
    font-weight: 600;
}

/* Responsive Tables */
@media (max-width: 768px) {
    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

/* Sections */
section {
    margin: 2rem 0;
}

/* Cards */
.card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s;
}

.card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.1);
}

/* Grid Layouts */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-lighter);
    color: var(--primary-color);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error State */
.error {
    color: #d32f2f;
    padding: 1rem;
    background: #ffebee;
    border-radius: 4px;
    margin: 1rem 0;
}

@media (prefers-color-scheme: dark) {
    .error {
        background: #3a1a1a;
        color: #ff6b6b;
    }
}

/* Success State */
.success {
    color: #388e3c;
    padding: 1rem;
    background: #e8f5e9;
    border-radius: 4px;
    margin: 1rem 0;
}

@media (prefers-color-scheme: dark) {
    .success {
        background: #1a3a1a;
        color: #66bb6a;
    }
}

/* Print Styles */
@media print {
    header, footer, .no-print {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    a {
        color: black;
    }
}

/* Performance: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-lighter);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Selection */
::selection {
    background: var(--primary-color);
    color: white;
}

/* Hamburger button (hidden on desktop) */
.nav-toggle {
  display: none;                 /* shown in mobile @media */
  width: 40px;
  height: 40px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  color: #111827;                /* sets bar color via currentColor */
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  display: none;
  /* Add this: stack bars vertically */
  display: none;
  /* The only critical addition: */
  flex-direction: column;        /* <--- stack bars */
}

.nav-toggle .bar {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;      /* use button color */
  border-radius: 2px;
}

/* Improve contrast in dark mode */
@media (prefers-color-scheme: dark) {
  .nav-toggle {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #e5e7eb;              /* bars become light */
  }
}

/* Mobile: show the button */
@media (max-width: 768px) {
  .nav-toggle { display: inline-flex; }
}
