/* CSS Reset for Cross-Browser Compatibility */
/* Fixes text rendering issues, especially on Mac browsers */

/* Box-sizing reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Remove default margin and padding */
* {
    margin: 0;
    padding: 0;
}

/* HTML and body reset */
html {
    line-height: 1.15; /* Correct line height in all browsers */
    -webkit-text-size-adjust: 100%; /* Prevent adjustments of font size after orientation changes in iOS */
    -webkit-font-smoothing: antialiased; /* Better font rendering on Mac */
    -moz-osx-font-smoothing: grayscale; /* Better font rendering on Mac Firefox */
    text-rendering: optimizeLegibility; /* Better text rendering */
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background-color: #0a0a0a; /* fallback for when gradient isn't supported */
    background-image: var(--app-radial-bg);
    background-repeat: no-repeat;
    background-position: 50% 0; /* center horizontally, top vertically */
    background-attachment: fixed;
    background-size: cover;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Brand loading state - prevent flash of base theme colors */
body.brand-loading,
html.brand-loading {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

body.brand-loaded,
html.brand-loaded {
    opacity: 1;
}

/* Remove list styles */
ol, ul {
    list-style: none;
}

/* Remove quotes from blockquotes and q elements */
blockquote, q {
    quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}

/* Table reset */
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* Form elements reset */
button, input, optgroup, select, textarea {
    font-family: inherit;
    font-size: 100%;
    line-height: 1.15;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input {
    overflow: visible;
}

button, select {
    text-transform: none;
}

/* Fix button styling in Safari */
button,
[type="button"],
[type="reset"],
[type="submit"] {
    -webkit-appearance: button;
    appearance: button;
    background-color: transparent;
    border: 0;
    cursor: pointer;
}

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
    border-style: none;
    padding: 0;
}

button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
    outline: 1px dotted ButtonText;
}

/* Text input reset */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: transparent;
    border: 1px solid #ccc;
    border-radius: 0;
    padding: 8px 12px;
    font-size: inherit;
    line-height: inherit;
}

textarea {
    resize: vertical;
    overflow: auto;
}

/* Remove search input styling in Safari */
input[type="search"] {
    -webkit-appearance: textfield;
    appearance: textfield;
    outline-offset: -2px;
}

input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
}

/* Media elements */
img, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Remove default link styling */
a {
    background-color: transparent;
    text-decoration: none;
    color: inherit;
}

a:active,
a:hover {
    outline: 0;
}

/* Heading reset */
h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    margin: 0;
}

/* Paragraph reset */
p {
    margin: 0;
}

/* Address styling not present in Safari */
abbr[title] {
    border-bottom: none;
    text-decoration: underline;
    text-decoration: underline dotted;
}

b, strong {
    font-weight: bolder;
}

/* Code elements */
code, kbd, samp {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 1em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Small text */
small {
    font-size: 80%;
}

/* Prevent subscript and superscript affecting line-height */
sub, sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

sub {
    bottom: -0.25em;
}

sup {
    top: -0.5em;
}

/* Hidden elements */
[hidden] {
    display: none;
}

/* Focus styles for accessibility */
:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

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

/* Selection styles */
::selection {
    background-color: #4A90E2;
    color: white;
}

::-moz-selection {
    background-color: #4A90E2;
    color: white;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Fix for Mac Safari text rendering issues */
@media screen and (-webkit-min-device-pixel-ratio: 1.25) {
    body {
        -webkit-font-smoothing: subpixel-antialiased;
    }
}

/* Print styles */
@media print {
    *, *:before, *:after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}

/* ========================= */
/* EXISTING BASE CSS STYLES  */
/* ========================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family-primary);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Common Button Styles - Now theme-aware */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    color: inherit;
}

.theme-toggle:hover {
    background: var(--hover-overlay);
}

/* Global utility classes and animations */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

.scale-in {
    animation: fadeInScale 0.3s ease;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 2px solid var(--border-color-light);
    border-top: 2px solid var(--brand-primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

/* Hide/show utilities */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Text utilities */
.text-center {
    text-align: center;
}

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

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

.text-primary {
    color: var(--brand-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-danger {
    color: var(--color-danger);
}

.text-success {
    color: var(--color-success);
}

/* Spacing utilities */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

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

@keyframes slideIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive utilities */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}
