/* =====================================================
   KODI APPS THEME - CORE.CSS
   Structural foundation: resets, typography, spacing, grid
   Always loaded. Uses var() only - no hardcoded colors.
   ===================================================== */

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

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 500;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===================== TYPOGRAPHY ===================== */

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1 { font-size: var(--font-size-4xl, 2.25rem); }
h2 { font-size: var(--font-size-3xl, 1.875rem); }
h3 { font-size: var(--font-size-2xl, 1.5rem); }
h4 { font-size: var(--font-size-xl, 1.25rem); }
h5 { font-size: var(--font-size-lg, 1.125rem); }
h6 { font-size: var(--font-size-base, 1rem); }

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}
a:hover { opacity: 0.85; }

small { font-size: var(--font-size-sm, 0.875rem); color: var(--text-tertiary); }
strong { font-weight: 700; }
code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: var(--font-size-sm, 0.875rem);
    background: var(--bg-secondary);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm, 0.25rem);
    border: 1px solid var(--border-primary);
}

pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md, 0.5rem);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}
pre code { background: none; border: none; padding: 0; }

blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-sm, 0.25rem) var(--radius-sm, 0.25rem) 0;
    color: var(--text-secondary);
}

hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 1.5rem 0;
}

/* Lists */
ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; }
li { margin-bottom: 0.25rem; color: var(--text-secondary); }

/* ===================== LAYOUT ===================== */

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section { padding: 2rem 0; }

/* Grid System */
.grid { display: grid; gap: var(--spacing-md, 1rem); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--spacing-xs, 0.25rem); }
.gap-sm { gap: var(--spacing-sm, 0.5rem); }
.gap-md { gap: var(--spacing-md, 1rem); }
.gap-lg { gap: var(--spacing-lg, 1.5rem); }
.gap-xl { gap: var(--spacing-xl, 2rem); }

/* ===================== SPACING ===================== */

.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 0.75rem; }
.m-4 { margin: 1rem; }
.m-6 { margin: 1.5rem; }
.m-8 { margin: 2rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; } .mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; } .mb-8 { margin-bottom: 2rem; }
.ml-1 { margin-left: 0.25rem; } .ml-2 { margin-left: 0.5rem; } .ml-4 { margin-left: 1rem; }
.mr-1 { margin-right: 0.25rem; } .mr-2 { margin-right: 0.5rem; } .mr-4 { margin-right: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.pt-1 { padding-top: 0.25rem; } .pt-2 { padding-top: 0.5rem; } .pt-4 { padding-top: 1rem; }
.pb-1 { padding-bottom: 0.25rem; } .pb-2 { padding-bottom: 0.5rem; } .pb-4 { padding-bottom: 1rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

/* ===================== DISPLAY ===================== */

.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.hidden { display: none; }
.invisible { visibility: hidden; }

/* ===================== TEXT ===================== */

.text-xs { font-size: var(--font-size-xs, 0.75rem); }
.text-sm { font-size: var(--font-size-sm, 0.875rem); }
.text-base { font-size: var(--font-size-base, 1rem); }
.text-lg { font-size: var(--font-size-lg, 1.125rem); }
.text-xl { font-size: var(--font-size-xl, 1.25rem); }
.text-2xl { font-size: var(--font-size-2xl, 1.5rem); }
.text-3xl { font-size: var(--font-size-3xl, 1.875rem); }
.text-4xl { font-size: var(--font-size-4xl, 2.25rem); }

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

.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; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-tertiary); opacity: 0.7; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== BORDERS ===================== */

.rounded-sm { border-radius: var(--radius-sm, 0.25rem); }
.rounded { border-radius: var(--radius-md, 0.5rem); }
.rounded-lg { border-radius: var(--radius-lg, 0.75rem); }
.rounded-xl { border-radius: var(--radius-xl, 1rem); }
.rounded-full { border-radius: 9999px; }
.border { border: 1px solid var(--border-primary); }
.border-2 { border: 2px solid var(--border-primary); }
.border-accent { border-color: var(--accent); }
.border-none { border: none; }

/* ===================== SHADOWS ===================== */

.shadow-sm { box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.1)); }
.shadow { box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,0.15)); }
.shadow-lg { box-shadow: var(--shadow-lg, 0 4px 16px rgba(0,0,0,0.2)); }
.shadow-none { box-shadow: none; }

/* ===================== TRANSITIONS ===================== */

.transition { transition: all 0.2s ease; }
.transition-fast { transition: all 0.15s ease; }
.transition-slow { transition: all 0.3s ease; }

/* Theme transition class (added during theme switch) */
.theme-transitioning,
.theme-transitioning * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 640px) {
    .sm\:hidden { display: none; }
    .sm\:block { display: block; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .md\:hidden { display: none; }
    .md\:block { display: block; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1025px) {
    .lg\:hidden { display: none; }
    .lg\:block { display: block; }
}

/* ===================== ACCESSIBILITY ===================== */

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

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

/* ===================== SCROLLBAR ===================== */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===================== SELECTION ===================== */

::selection {
    background: var(--accent);
    color: var(--bg-primary);
}

/* ===================== PRINT ===================== */

@media print {
    body { background: #fff; color: #000; }
    .no-print { display: none; }
}
