/* Base styles: CSS variables, resets, and base element styling */

/* CSS Variables */
:root {
    /* Color palette */
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #7c3aed;
    --accent-color: #06b6d4;
    --background-color: #f8fafc;
    --text-color: #1e293b;
    --text-light: #64748b;
    --text-dark: #0f172a;
    --success-color: #10b981;
    --error-color: #ef4444;
    --surface-color: #ffffff;
    --surface-hover: #f1f5f9;
    --border-color: #e2e8f0;
    
    /* Typography */
    --font-family: 'Poppins', sans-serif;
    --font-family-secondary: 'Open Sans', sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    
    /* Border radius */
    --border-radius-sm: 6px;
    --border-radius: 10px;
    --border-radius-lg: 16px;
    
    /* Transitions */
    --transition: all 0.3s ease;
}

/* Dark mode colors */
:root.dark-mode {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --background-color: #0f172a;
    --text-color: #e2e8f0;
    --text-light: #94a3b8;
    --text-dark: #f1f5f9;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --border-color: #334155;
}

/* Reset styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base HTML elements */
html {
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography base styles */
h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-dark);
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

p {
    margin-bottom: 1rem;
}

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

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

/* Form elements */
button, input, select, textarea {
    font-family: inherit;
    font-size: 100%;
    line-height: 1.15;
    margin: 0;
}

button {
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: var(--font-family);
    font-weight: 500;
}

input, textarea {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    outline: none;
    background-color: var(--surface-color);
    color: var(--text-color);
    transition: border-color 0.2s;
}

input:focus, textarea:focus {
    border-color: var(--primary-color);
}

select {
    appearance: none;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    color: var(--text-color);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select:focus {
    border-color: var(--primary-color);
}

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

/* Remove default style for focus visible on keyboard-only users */
:focus:not(:focus-visible) {
    outline: none;
}

/* Add style for keyboard focus */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Hiding content visually but keeping it accessible for screen readers */
.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;
}

/* Create a mixin for smooth transitions */
.with-transition {
    transition: var(--transition);
}

/* Global code styling */
code, pre {
    font-family: 'Fira Code', 'Courier New', monospace;
}

pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--surface-hover);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin: 1rem 0;
}

code {
    font-size: 0.875rem;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    background-color: var(--surface-hover);
}

pre code {
    background-color: transparent;
    padding: 0;
}

/* Prevent zooming on mobile when focusing on inputs */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px;
    }
}

/* iOS Safari viewport height fix */
@supports (-webkit-touch-callout: none) {
    body, html {
        height: -webkit-fill-available;
    }
}
