/* ==========================================================================
MicroImageTools Core Design System & Styling
========================================================================== */

/* 1. CSS Custom Properties (Theme System) */
:root {
/* Light Theme */
--bg-primary: #F8FAFC;
--bg-surface: #FFFFFF;
--bg-card: #FFFFFF;
--text-primary: #111827;
--text-muted: #64748B;
--border-color: #E2E8F0;
--border-hover: #CBD5E1;

--primary: #635BFF;
--primary-hover: #4F46E5;
--primary-light: rgba(99, 91, 255, 0.08);

--accent-green: #16A34A;
--accent-green-bg: #DCFCE7;
--accent-warning: #D97706;
--accent-warning-bg: #FEF3C7;
--accent-danger: #DC2626;
--accent-danger-bg: #FEE2E2;

--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
--shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);

--radius-sm: 6px;
--radius-md: 10px;
--radius-lg: 16px;
--radius-full: 9999px;

--font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
--transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
--transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
/* Dark Theme Overrides */
--bg-primary: #0B1020;
--bg-surface: #111827;
--bg-card: #1E293B;
--text-primary: #F8FAFC;
--text-muted: #94A3B8;
--border-color: #263244;
--border-hover: #334155;

--primary: #7C73FF;
--primary-hover: #635BFF;
--primary-light: rgba(124, 115, 255, 0.15);

--accent-green-bg: rgba(22, 163, 74, 0.2);
--accent-warning-bg: rgba(217, 119, 6, 0.2);
--accent-danger-bg: rgba(220, 38, 38, 0.2);

--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
--shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* 2. Global Reset & Base Typography */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

html {
font-family: var(--font-family);
font-size: 16px;
line-height: 1.6;
color: var(--text-primary);
background-color: var(--bg-primary);
scroll-behavior: smooth;
-webkit-text-size-adjust: 100%;
}

body {
min-height: 100vh;
display: flex;
flex-direction: column;
}

main {
flex: 1 0 auto;
}

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

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

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

p {
margin-bottom: 1rem;
}

p:last-child {
margin-bottom: 0;
}

ul, ol {
margin-bottom: 1rem;
padding-left: 1.5rem;
}

/* 3. Layout Structure */
.container {
width: 100%;
max-width: 1240px;
margin: 0 auto;
padding: 0 1.25rem;
}

/* 4. Navigation & Header */
.site-header {
position: sticky;
top: 0;
z-index: 100;
background-color: var(--bg-surface);
border-bottom: 1px solid var(--border-color);
backdrop-filter: blur(8px);
}

.header-container {
display: flex;
align-items: center;
justify-content: space-between;
height: 70px;
}

.logo {
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 800;
font-size: 1.25rem;
color: var(--text-primary);
}

.logo-icon {
width: 32px;
height: 32px;
flex-shrink: 0;
}

.nav-desktop {
display: flex;
align-items: center;
gap: 2rem;
}

.nav-link {
color: var(--text-muted);
font-weight: 500;
font-size: 0.95rem;
padding: 0.5rem 0;
border-bottom: 2px solid transparent;
transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
color: var(--primary);
border-bottom-color: var(--primary);
}

.header-actions {
display: flex;
align-items: center;
gap: 0.75rem;
}

.btn-icon {
background: transparent;
border: 1px solid var(--border-color);
color: var(--text-primary);
width: 40px;
height: 40px;
border-radius: var(--radius-md);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all var(--transition-fast);
}

.btn-icon:hover {
background-color: var(--primary-light);
border-color: var(--primary);
color: var(--primary);
}

.btn-icon svg {
width: 20px;
height: 20px;
}

.icon-sun { display: block; }
.icon-moon { display: none; }

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.mobile-only { display: none; }
.mobile-nav-drawer { display: none; }

/* 5. Hero Section */
.hero-section {
padding: 4.5rem 0 3rem;
text-align: center;
background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-primary) 100%);
border-bottom: 1px solid var(--border-color);
}

.badge {
display: inline-block;
padding: 0.35rem 0.85rem;
background-color: var(--primary-light);
color: var(--primary);
font-size: 0.85rem;
font-weight: 600;
border-radius: var(--radius-full);
margin-bottom: 1.25rem;
}

.hero-title {
font-size: 2.75rem;
letter-spacing: -0.02em;
margin-bottom: 1.25rem;
}

.hero-subheadline {
max-width: 680px;
margin: 0 auto 2rem;
font-size: 1.15rem;
color: var(--text-muted);
}

.hero-actions {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
margin-bottom: 3rem;
}

.trust-indicators {
display: flex;
align-items: center;
justify-content: center;
gap: 2rem;
flex-wrap: wrap;
}

.trust-item {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.9rem;
color: var(--text-muted);
}

.trust-item svg {
width: 18px;
height: 18px;
color: var(--primary);
}

/* 6. Buttons & Inputs */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.75rem 1.5rem;
font-size: 1rem;
font-weight: 600;
border-radius: var(--radius-md);
border: 1px solid transparent;
cursor: pointer;
transition: all var(--transition-fast);
text-align: center;
}

.btn-primary {
background-color: var(--primary);
color: #FFFFFF !important;
}

.btn-primary:hover {
background-color: var(--primary-hover);
box-shadow: 0 4px 12px rgba(99, 91, 255, 0.3);
}

.btn-secondary {
background-color: var(--bg-surface);
border-color: var(--border-color);
color: var(--text-primary);
}

.btn-secondary:hover {
border-color: var(--primary);
color: var(--primary);
}

.form-group {
margin-bottom: 1.25rem;
text-align: left;
}

.form-label {
display: block;
font-size: 0.9rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: var(--text-primary);
}

.form-control {
width: 100%;
padding: 0.75rem 1rem;
font-size: 1rem;
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
background-color: var(--bg-surface);
color: var(--text-primary);
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
}

/* 7. Search Bar */
.search-section {
padding: 2rem 0;
}

.search-wrapper {
position: relative;
max-width: 640px;
margin: 0 auto;
}

.search-icon {
position: absolute;
left: 1.25rem;
top: 50%;
transform: translateY(-50%);
width: 20px;
height: 20px;
color: var(--text-muted);
}

.search-wrapper input {
width: 100%;
padding: 1rem 3.5rem 1rem 3.25rem;
font-size: 1.05rem;
border-radius: var(--radius-lg);
border: 1px solid var(--border-color);
background-color: var(--bg-surface);
color: var(--text-primary);
box-shadow: var(--shadow-sm);
transition: all var(--transition-fast);
}

.search-wrapper input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 4px var(--primary-light);
}

.search-shortcut-hint {
position: absolute;
right: 1.25rem;
top: 50%;
transform: translateY(-50%);
background-color: var(--bg-primary);
border: 1px solid var(--border-color);
padding: 0.15rem 0.5rem;
border-radius: var(--radius-sm);
font-size: 0.8rem;
color: var(--text-muted);
}

.search-clear-btn {
position: absolute;
right: 3rem;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
font-size: 1.25rem;
color: var(--text-muted);
cursor: pointer;
}

/* 8. Tool Cards & Grid */
.tools-section {
padding: 2rem 0 4rem;
}

.section-header {
text-align: center;
max-width: 640px;
margin: 0 auto 2.5rem;
}

.section-header h2 {
font-size: 2rem;
}

.section-header p {
color: var(--text-muted);
}

.category-pills {
display: flex;
justify-content: center;
gap: 0.5rem;
flex-wrap: wrap;
margin-bottom: 2rem;
}

.pill-btn {
background: var(--bg-surface);
border: 1px solid var(--border-color);
padding: 0.5rem 1.25rem;
border-radius: var(--radius-full);
font-size: 0.9rem;
font-weight: 500;
color: var(--text-muted);
cursor: pointer;
transition: all var(--transition-fast);
}

.pill-btn:hover, .pill-btn.active {
background: var(--primary);
color: #FFFFFF;
border-color: var(--primary);
}

.tools-cards-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 1.5rem;
}

.tool-card {
background-color: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
padding: 1.75rem;
display: flex;
flex-direction: column;
transition: all var(--transition-normal);
box-shadow: var(--shadow-sm);
position: relative;
}

.tool-card:hover {
transform: translateY(-4px);
border-color: var(--primary);
box-shadow: var(--shadow-lg);
}

.card-badge {
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.05em;
color: var(--primary);
margin-bottom: 0.75rem;
}

.card-icon {
width: 48px;
height: 48px;
background-color: var(--primary-light);
border-radius: var(--radius-md);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1.25rem;
color: var(--primary);
}

.card-icon svg {
width: 26px;
height: 26px;
}

.tool-card h3 {
font-size: 1.25rem;
margin-bottom: 0.5rem;
}

.tool-card p {
color: var(--text-muted);
font-size: 0.95rem;
margin-bottom: 1.5rem;
flex: 1 0 auto;
}

.tool-btn {
font-weight: 600;
font-size: 0.95rem;
display: inline-flex;
align-items: center;
gap: 0.25rem;
}

.no-results-box {
text-align: center;
padding: 4rem 1rem;
background-color: var(--bg-surface);
border: 1px dashed var(--border-color);
border-radius: var(--radius-lg);
}

.no-results-box svg {
width: 48px;
height: 48px;
color: var(--text-muted);
margin-bottom: 1rem;
}

/* 9. Tool App Card Layout (Inside Individual Tool Pages) */
.breadcrumb-nav {
padding: 1.5rem 0 0;
}

.breadcrumb-list {
display: flex;
align-items: center;
gap: 0.5rem;
list-style: none;
padding: 0;
font-size: 0.875rem;
color: var(--text-muted);
}

.breadcrumb-list li::after {
content: "/";
margin-left: 0.5rem;
}

.breadcrumb-list li:last-child::after {
content: "";
}

.tool-page-header {
padding: 1.5rem 0 2rem;
}

.tool-page-header h1 {
font-size: 2.25rem;
}

.tool-app-card {
background-color: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
padding: 2rem;
box-shadow: var(--shadow-md);
margin-bottom: 3rem;
}

.calculator-results {
background-color: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 1.5rem;
margin-top: 1.5rem;
}

.results-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 1rem;
}

.result-box {
background-color: var(--bg-surface);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 1rem;
text-align: center;
}

.result-val {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary);
line-height: 1.2;
}

.result-lbl {
font-size: 0.8rem;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
margin-top: 0.25rem;
}

.preset-btns {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-top: 0.5rem;
}

.preset-btn {
background: var(--bg-primary);
border: 1px solid var(--border-color);
padding: 0.35rem 0.75rem;
border-radius: var(--radius-sm);
font-size: 0.85rem;
cursor: pointer;
color: var(--text-primary);
}

.preset-btn:hover {
border-color: var(--primary);
color: var(--primary);
}

.inline-error {
color: var(--accent-danger);
font-size: 0.85rem;
margin-top: 0.35rem;
display: block;
}

/* 10. File Upload & Interactive Utility UI */
.drop-zone {
border: 2px dashed var(--border-color);
border-radius: var(--radius-lg);
padding: 3rem 1.5rem;
text-align: center;
background-color: var(--bg-primary);
cursor: pointer;
transition: all var(--transition-fast);
position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
border-color: var(--primary);
background-color: var(--primary-light);
}

.drop-zone svg {
width: 48px;
height: 48px;
color: var(--primary);
margin-bottom: 1rem;
}

.file-input-hidden {
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
opacity: 0;
cursor: pointer;
}

.preview-container {
max-width: 100%;
max-height: 400px;
overflow: hidden;
border-radius: var(--radius-md);
margin: 1.5rem 0;
display: flex;
align-items: center;
justify-content: center;
background: #00000010;
}

.preview-container img {
max-width: 100%;
max-height: 400px;
object-fit: contain;
}

.color-swatches-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
gap: 1rem;
margin-top: 1.5rem;
}

.swatch-card {
background-color: var(--bg-surface);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
overflow: hidden;
box-shadow: var(--shadow-sm);
}

.swatch-color {
height: 100px;
width: 100%;
}

.swatch-info {
padding: 0.75rem;
}

.swatch-code {
font-family: monospace;
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.35rem;
}

.btn-copy {
background: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 0.2rem 0.5rem;
font-size: 0.75rem;
cursor: pointer;
}

/* 11. Explanatory & Content Sections */
.tool-content-section {
padding: 2rem 0;
border-top: 1px solid var(--border-color);
}

.formula-box {
background-color: var(--bg-surface);
border-left: 4px solid var(--primary);
padding: 1.25rem 1.5rem;
border-radius: 0 var(--radius-md) var(--radius-md) 0;
margin: 1.5rem 0;
font-family: monospace;
font-size: 1rem;
}

/* 12. Privacy Banner & Step Grid */
.privacy-banner-section {
padding: 2rem 0;
}

.privacy-box {
background-color: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
padding: 2rem;
display: flex;
align-items: flex-start;
gap: 1.5rem;
}

.privacy-icon {
width: 48px;
height: 48px;
background-color: var(--primary-light);
border-radius: var(--radius-md);
display: flex;
align-items: center;
justify-content: center;
color: var(--primary);
flex-shrink: 0;
}

.privacy-icon svg { width: 28px; height: 28px; }

.how-section {
padding: 4rem 0;
}

.steps-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
}

.step-card {
background-color: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
padding: 2rem;
text-align: center;
position: relative;
}

.step-number {
width: 40px;
height: 40px;
background-color: var(--primary);
color: #FFFFFF;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
margin: 0 auto 1.25rem;
}

/* 13. FAQ Accordion */
.faq-section {
padding: 3rem 0 5rem;
}

.faq-accordion {
max-width: 800px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 1rem;
}

.faq-item {
background-color: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
overflow: hidden;
}

.faq-question {
padding: 1.25rem 1.5rem;
font-weight: 600;
font-size: 1.05rem;
cursor: pointer;
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
}

.faq-question::-webkit-details-marker { display: none; }

.faq-question::after {
content: "+";
font-size: 1.5rem;
color: var(--primary);
}

details[open] .faq-question::after {
content: "−";
}

.faq-answer {
padding: 0 1.5rem 1.25rem;
color: var(--text-muted);
}

/* 14. Footer */
.site-footer {
background-color: var(--bg-surface);
border-top: 1px solid var(--border-color);
padding: 4rem 0 2rem;
}

.footer-grid {
display: grid;
grid-template-columns: 2fr repeat(3, 1fr);
gap: 3rem;
margin-bottom: 3rem;
}

.footer-col h4 {
font-size: 1rem;
margin-bottom: 1.25rem;
}

.footer-col ul {
list-style: none;
padding: 0;
}

.footer-col li {
margin-bottom: 0.75rem;
}

.footer-col a {
color: var(--text-muted);
font-size: 0.9rem;
}

.footer-col a:hover {
color: var(--primary);
}

.footer-bottom {
border-top: 1px solid var(--border-color);
padding-top: 2rem;
text-align: center;
font-size: 0.875rem;
color: var(--text-muted);
}

/* 15. Toast Notification System */
.toast-container {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
display: flex;
flex-direction: column;
gap: 10px;
}

.toast {
background-color: var(--text-primary);
color: var(--bg-primary);
padding: 0.75rem 1.25rem;
border-radius: var(--radius-md);
font-size: 0.9rem;
font-weight: 500;
box-shadow: var(--shadow-lg);
display: flex;
align-items: center;
gap: 0.5rem;
animation: toastIn 0.2s ease forwards;
}

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

/* 16. Mobile Responsive Adjustments */
@media (max-width: 992px) {
.hero-title { font-size: 2.25rem; }
.footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
.nav-desktop { display: none; }
.mobile-only { display: flex; }

.mobile-nav-drawer {
display: flex;
flex-direction: column;
position: absolute;
top: 70px;
left: 0;
right: 0;
background-color: var(--bg-surface);
border-bottom: 1px solid var(--border-color);
padding: 1rem 1.25rem;
gap: 0.75rem;
box-shadow: var(--shadow-md);
}

.mobile-nav-drawer[aria-hidden="true"] {
display: none;
}

.mobile-nav-link {
padding: 0.75rem 0;
font-size: 1.05rem;
font-weight: 500;
color: var(--text-primary);
border-bottom: 1px solid var(--border-color);
}

.hero-title { font-size: 1.85rem; }
.hero-subheadline { font-size: 1rem; }
.hero-actions { flex-direction: column; }
.btn { width: 100%; }

.footer-grid { grid-template-columns: 1fr; }
.privacy-box { flex-direction: column; }
}