/**
 * RailBud - Base Styles
 * Reset, typography, and foundational styles
 */

/* ========================================
   CSS RESET & NORMALIZE
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Remove default tap highlights and touch behaviors */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ========================================
   FOCUS STYLES
   ======================================== */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* ========================================
   SELECTION
   ======================================== */
::selection {
    background-color: var(--color-primary-500);
    color: white;
}

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

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}

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

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p {
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-default);
}

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

[data-theme="dark"] a:hover {
    color: var(--color-primary-300);
}

strong, b {
    font-weight: var(--font-semibold);
}

small {
    font-size: var(--text-xs);
}

/* ========================================
   LISTS
   ======================================== */
ul, ol {
    list-style: none;
}

/* ========================================
   IMAGES & MEDIA
   ======================================== */
img, svg, video, canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ========================================
   FORM ELEMENTS RESET
   ======================================== */
button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
}

button {
    cursor: pointer;
    user-select: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder);
    opacity: 1;
}

input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    appearance: none;
    -webkit-appearance: none;
}

/* Remove autofill styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0px 1000px var(--input-bg) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* ========================================
   TABLE RESET
   ======================================== */
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* ========================================
   HIDDEN & VISIBILITY
   ======================================== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.invisible {
    visibility: hidden;
}

/* ========================================
   LUCIDE ICONS BASE
   ======================================== */
[data-lucide] {
    width: 1em;
    height: 1em;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Icon Sizes */
.icon-xs { width: 0.75rem; height: 0.75rem; }
.icon-sm { width: 0.875rem; height: 0.875rem; }
.icon-md { width: 1rem; height: 1rem; }
.icon-lg { width: 1.25rem; height: 1.25rem; }
.icon-xl { width: 1.5rem; height: 1.5rem; }

/* ========================================
   UTILITY CLASSES
   ======================================== */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success-600); }
.text-warning { color: var(--color-warning-600); }
.text-error { color: var(--color-error-600); }

[data-theme="dark"] .text-success { color: var(--color-success-500); }
[data-theme="dark"] .text-warning { color: var(--color-warning-500); }
[data-theme="dark"] .text-error { color: var(--color-error-500); }