/* 
   common.css - Shared Design System for tools.j4ck.xyz
   Provides typography, interactive element styles, and auto dark/light modes.
*/

:root,
:root.theme-light {
  /* Light Theme Variables */
  --bg-page: oklch(0.98 0.005 240);
  --bg-surface: oklch(1.0 0 0);
  --text-primary: oklch(0.25 0.01 240);
  --text-secondary: oklch(0.5 0.01 240);
  --accent: oklch(0.55 0.18 250);
  --accent-hover: oklch(0.48 0.18 250);
  --accent-bg-subtle: oklch(0.95 0.015 250);
  --border-color: oklch(0.9 0.01 240);
  --input-bg: oklch(1.0 0 0);
  --input-border: oklch(0.85 0.01 240);
  --input-focus: oklch(0.55 0.18 250 / 0.15);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    /* Dark Theme Variables */
    --bg-page: oklch(0.14 0.01 240);
    --bg-surface: oklch(0.18 0.01 240);
    --text-primary: oklch(0.92 0.005 240);
    --text-secondary: oklch(0.7 0.01 240);
    --accent: oklch(0.65 0.16 250);
    --accent-hover: oklch(0.72 0.14 250);
    --accent-bg-subtle: oklch(0.22 0.02 250);
    --border-color: oklch(0.24 0.01 240);
    --input-bg: oklch(0.16 0.01 240);
    --input-border: oklch(0.26 0.01 240);
    --input-focus: oklch(0.65 0.16 250 / 0.25);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  }
}

:root.theme-dark {
  /* Forced Dark Theme Variables */
  --bg-page: oklch(0.14 0.01 240);
  --bg-surface: oklch(0.18 0.01 240);
  --text-primary: oklch(0.92 0.005 240);
  --text-secondary: oklch(0.7 0.01 240);
  --accent: oklch(0.65 0.16 250);
  --accent-hover: oklch(0.72 0.14 250);
  --accent-bg-subtle: oklch(0.22 0.02 250);
  --border-color: oklch(0.24 0.01 240);
  --input-bg: oklch(0.16 0.01 240);
  --input-border: oklch(0.26 0.01 240);
  --input-focus: oklch(0.65 0.16 250 / 0.25);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

/* Base Reset */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Container & Layout */
.container-custom {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0;
  letter-spacing: -0.025em;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Interactive Elements (Inputs, Buttons, Textareas) */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="url"],
select,
textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px; /* Exactly 16px to prevent iOS zoom issues */
  width: 100%;
  padding: 0.625rem 0.875rem;
  background-color: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--input-focus);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Label Styling */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  user-select: none;
  gap: 0.5rem;
}

.btn-custom-primary {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-custom-primary:hover {
  background-color: var(--accent-hover);
  text-decoration: none;
}

.btn-custom-primary:active {
  transform: scale(0.98);
}

.btn-custom-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-custom-secondary:hover {
  background-color: var(--bg-page);
  border-color: var(--text-secondary);
  text-decoration: none;
}

.btn-custom-secondary:active {
  transform: scale(0.98);
}

/* Cards & Containers */
.card-custom {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

/* Utility classes */
.text-muted-custom {
  color: var(--text-secondary);
}

/* Navigation / Header styling */
.header-custom {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  padding: 1rem 0;
  margin-bottom: 2rem;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.header-brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-brand:hover {
  text-decoration: none;
}

/* Search bar styling */
.search-wrapper {
  position: relative;
  margin-bottom: 2rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-input-custom {
  padding-left: 2.75rem !important;
  font-size: 1.05rem !important;
  border-radius: var(--radius-md) !important;
}

/* Responsive Overrides (if Bootstrap is loaded) */
.btn:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 3px var(--input-focus) !important;
  border-color: var(--accent) !important;
}

/* Custom styles to bridge Bootstrap 5 dark mode */
[data-bs-theme="dark"] {
  --bs-body-bg: var(--bg-page);
  --bs-body-color: var(--text-primary);
  --bs-tertiary-bg: var(--bg-surface);
  --bs-border-color: var(--border-color);
}
