/**
 * Base CSS - Core styles and reset
 * This file contains browser resets, typography, layout utilities
 * No theme-specific styles should be here
 */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    color: var(--color-text);
    background: var(--color-background);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin-bottom: var(--spacing-unit);
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--color-link-hover);
}

/* Layout Grid */
.app-container {
    display: grid;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    min-height: 100vh;
    gap: var(--layout-gap);
}

.app-sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-main {
    grid-area: main;
    padding: calc(var(--spacing-unit) * 3);
    overflow-x: hidden;
}

/* Content Grid */
.content-grid {
    display: grid;
    gap: calc(var(--spacing-unit) * 2);
}

.content-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.content-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.content-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Flexbox Utilities */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-gap {
    gap: var(--spacing-unit);
}

.flex-gap-lg {
    gap: calc(var(--spacing-unit) * 2);
}

/* Spacing Utilities */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-unit); }
.mt-2 { margin-top: calc(var(--spacing-unit) * 2); }
.mt-3 { margin-top: calc(var(--spacing-unit) * 3); }
.mt-4 { margin-top: calc(var(--spacing-unit) * 4); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-unit); }
.mb-2 { margin-bottom: calc(var(--spacing-unit) * 2); }
.mb-3 { margin-bottom: calc(var(--spacing-unit) * 3); }
.mb-4 { margin-bottom: calc(var(--spacing-unit) * 4); }

.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-unit); }
.p-2 { padding: calc(var(--spacing-unit) * 2); }
.p-3 { padding: calc(var(--spacing-unit) * 3); }
.p-4 { padding: calc(var(--spacing-unit) * 4); }

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

.text-bold { font-weight: 700; }
.text-normal { font-weight: 400; }
.text-light { font-weight: 300; }

.text-uppercase { text-transform: uppercase; }
.text-capitalize { text-transform: capitalize; }

.text-sm { font-size: 0.875rem; }
.text-md { font-size: 1rem; }
.text-lg { font-size: 1.25rem; }
.text-xl { font-size: 1.5rem; }

/* Visibility */
.hidden { display: none !important; }
.visible { display: block; }

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn var(--transition-speed) ease-in;
}

.slide-in-up {
    animation: slideInUp var(--transition-speed) ease-out;
}

.slide-in-right {
    animation: slideInRight var(--transition-speed) ease-out;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-areas:
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
    }

    .app-sidebar {
        display: none;
    }

    .app-main {
        padding: calc(var(--spacing-unit) * 2);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .content-grid-2,
    .content-grid-3,
    .content-grid-4 {
        grid-template-columns: 1fr;
    }

    .app-main {
        padding: var(--spacing-unit);
    }
}

/* Focus Styles */
*:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

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

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

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

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

/* Selection */
::selection {
    background: var(--color-selection-bg);
    color: var(--color-selection-text);
}
