/* WDK ONE Toolkit - Common Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-card: #18181b;
    --bg-card-hover: #1f1f23;
    --border-color: #27272a;
    --border-hover: #3f3f46;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.15);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px;
}

.container-wide {
    max-width: 1200px;
}

/* Header */
.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 24px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-light);
}

h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-desc {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Form Elements */
label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

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

/* Result/Output Areas */
.result-area {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Canvas Container */
.canvas-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    border-radius: 8px;
    max-width: 100%;
    background: #fff;
}

/* Color Picker */
input[type="color"] {
    width: 48px;
    height: 48px;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    appearance: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden { display: none; }

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

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

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

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

/* Auto-fix white background text color */
body::after {
    content: '';
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

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

    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Force readable text colors */
p, span, div, li, td, th, label {
    color: inherit;
}

/* Ensure input text is visible */
input[type="text"],
input[type="url"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
    color: var(--text-primary) !important;
}

/* Ensure option elements are visible */
option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Fix for any white backgrounds that might cause issues */
.white-bg {
    background: #fff;
    color: #000;
}

/* Critical fix: Force dark text on white/light backgrounds */
[style*="background: white"],
[style*="background:white"],
[style*="background-color: white"],
[style*="background-color:white"],
[style*="background: #fff"],
[style*="background:#fff"],
[style*="background-color: #fff"],
[style*="background-color:#fff"] {
    color: #000 !important;
}

/* Ensure nested elements also have dark text on white backgrounds */
[style*="background: white"] *,
[style*="background:white"] *,
[style*="background-color: white"] *,
[style*="background-color:white"] *,
[style*="background: #fff"] *,
[style*="background:#fff"] *,
[style*="background-color: #fff"] *,
[style*="background-color:#fff"] * {
    color: #000 !important;
}

/* Specific fixes for common white background elements */
.container[style*="background: white"],
.container[style*="background:#fff"],
.card[style*="background: white"],
.card[style*="background:#fff"],
.tool-card,
.control-group,
.preview-panel,
.setting-group,
.stat-item,
.image-item,
.gift-card,
.history-item,
.custom-food-item,
.round-result,
.result-item,
.info-card,
.example-code {
    color: #000 !important;
}

/* Ensure buttons and inputs on white backgrounds are visible */
[style*="background: white"] button,
[style*="background:#fff"] button,
[style*="background: white"] input,
[style*="background:#fff"] input,
[style*="background: white"] select,
[style*="background:#fff"] select,
[style*="background: white"] textarea,
[style*="background:#fff"] textarea {
    color: #000 !important;
}

/* Print Styles */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }

    .btn, .back-link {
        display: none;
    }
}

/* 
 * IMPORTANT: Add this script tag to your HTML files to auto-fix white background text:
 * <script src="fix-white-bg.js"></script>
 * 
 * Or add it at the end of common-styles.css import
 */
