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

:root {
    --primary: #1E40AF;
    --primary-light: #3B82F6;
    --dark: #1A1A1A;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --success: #059669;
    --danger: #DC2626;
    --warning: #D97706;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* Navbar */
.navbar {
    background: var(--dark);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s;
}

.nav-links a:hover { color: #fff; }

.cart-link { font-weight: 600; color: #fff !important; }

/* Messages */
.messages { margin-bottom: 1.5rem; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error { background: #FEE2E2; color: #991B1B; }
.alert-warning { background: #FEF3C7; color: #92400E; }
.alert-info { background: #DBEAFE; color: #1E40AF; }

/* Cards */
.card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--gray-900);
}

/* Forms */
label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group { margin-bottom: 1rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

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

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

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

.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.875rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* Color Swatches */
.color-swatches {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-swatch {
    position: relative;
    cursor: pointer;
}

.color-swatch input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.color-swatch .swatch {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 40px;
    border-radius: var(--radius);
    border: 2px solid var(--gray-200);
    font-size: 0.75rem;
    font-weight: 700;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.color-swatch input[type="radio"]:checked + .swatch {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.color-swatch .swatch:hover {
    border-color: var(--gray-500);
}

/* Tile Preview */
.tile-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 60px;
    text-align: center;
    border: 1px solid var(--gray-200);
}

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

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Tile Builder */
.tile-builder {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.builder-inputs {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

@media (max-width: 600px) {
    .builder-inputs {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

.tile-list { margin-top: 1rem; }

.tile-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.tile-list-item .word { font-weight: 600; flex: 1; }

.tile-list-item .remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
}

/* Pricing Banner */
.pricing-tiers {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.tier-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.tier-badge.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Pricing Summary */
.pricing-summary {
    border-top: 2px solid var(--gray-200);
    padding-top: 1rem;
    margin-top: 1rem;
}

.pricing-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.9rem;
}

.pricing-row.total {
    font-size: 1.1rem;
    font-weight: 700;
    border-top: 1px solid var(--gray-200);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.discount-hint {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #FEF3C7;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #92400E;
}

/* Order Status Badge */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending { background: #FEF3C7; color: #92400E; }
.status-paid { background: #DBEAFE; color: #1E40AF; }
.status-generating { background: #E0E7FF; color: #4338CA; }
.status-ready { background: #D1FAE5; color: #065F46; }
.status-printing { background: #FEE2E2; color: #991B1B; }
.status-shipped { background: #D1FAE5; color: #065F46; }
.status-cancelled { background: var(--gray-200); color: var(--gray-500); }

/* Success Page */
.success-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 1rem;
}

.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Footer */
.footer {
    background: var(--gray-100);
    border-top: 1px solid var(--gray-200);
    padding: 1.5rem 0;
    margin-top: auto;
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Quantity input in tables */
input[type="number"].qty-input {
    width: 70px;
    text-align: center;
    padding: 0.375rem;
}
