@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #10b981;
    --accent-hover: #34d399;
    --danger-color: #ef4444;
    --danger-hover: #f87171;
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 9999px;
    --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.3);
}

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

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Glassmorphic Navbar */
header {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.2rem 2.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent-color), #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

header nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

header nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
}

header nav a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

header nav a.active, 
header nav a[style*="var(--accent-color)"] {
    color: var(--accent-color) !important;
    background: rgba(16, 185, 129, 0.1);
}

header nav a[style*="var(--danger-color)"] {
    color: var(--danger-color) !important;
    background: rgba(239, 68, 68, 0.1);
}

/* Main Container */
main {
    flex: 1;
    max-width: 1000px;
    margin: 2rem auto;
    width: 100%;
    padding: 0 1.5rem;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Typography */
h2, h3 {
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 1rem;
}

p.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* Forms & Inputs */
input[type="text"], input[type="number"], input[type="password"], input[type="file"] {
    width: 100%;
    padding: 0.8rem 1.2rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Buttons */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--font-family);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover, .btn:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}

button:active, .btn:active {
    transform: translateY(0);
}

button.primary, .btn.primary {
    background: var(--accent-color);
    color: #000;
    border: none;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

button.primary:hover, .btn.primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

button.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-hover);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

button.danger:hover {
    background: var(--danger-color);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

/* Sections & Cards */
.section-block {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 50px -10px rgba(0,0,0,0.4);
}

/* Model Input Area */
.model-section {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
}

.model-section h2 {
    color: var(--accent-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
}

.model-section input {
    max-width: 350px;
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 3px;
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* Hide number spinner on model input */
.model-section input::-webkit-outer-spin-button,
.model-section input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.model-section input[type=number] {
  -moz-appearance: textfield;
}

#productImageContainer {
    margin-top: 2rem;
}

#productImageContainer img {
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease;
}

#productImageContainer img:hover {
    transform: scale(1.05);
}

/* Grid Selections */
.search-bar {
    border-radius: var(--radius-pill) !important;
    padding: 0.8rem 1.5rem !important;
    background: rgba(0,0,0,0.2) !important;
}

.grid-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1rem;
}

.selectable-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-pill);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.selectable-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.3);
}

.selectable-btn.selected {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* Barcode Cards */
.barcode-result-area {
    margin-top: 3rem;
}

.color-group {
    margin-bottom: 3.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.color-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.color-group-title {
    color: var(--accent-color);
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    padding-left: 0.8rem;
    border-left: 4px solid var(--accent-color);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.barcode-card {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.barcode-card:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.barcode-card.copied {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #000;
}

.barcode-card.copied .text-info h3,
.barcode-card.copied .text-info p {
    color: #000;
}

.print-btn {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
}

.print-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #000;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

.barcode-card.copied .print-btn {
    opacity: 0;
    pointer-events: none;
}

.copy-toast {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: #000;
    background: rgba(255, 255, 255, 0.4);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
}

.barcode-card.copied .copy-toast {
    opacity: 1;
}

.barcode-card .qr-placeholder {
    width: 115px;
    height: 115px;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.barcode-card .qr-placeholder canvas,
.barcode-card .qr-placeholder img {
    max-width: 100% !important;
    max-height: 100% !important;
}

.barcode-card .text-info {
    flex: 1;
}

.barcode-card .text-info h3 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.barcode-card .text-info p {
    margin: 0.2rem 0 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Admin Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 1rem;
}

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

table th {
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

table tbody tr {
    transition: background 0.2s;
}

table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

/* Scanner specific */
#reader {
    width: 100%;
    max-width: 700px;
    margin: 0 auto 2rem auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft);
    background: #000;
}

.product-info-card {
    text-align: center;
    display: none;
}

.product-info-card.active {
    display: block;
    animation: fadeUp 0.5s ease;
}

.product-image-placeholder {
    width: 250px;
    height: 300px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    margin: 0 auto 1.5rem auto;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px dashed var(--card-border);
}

.product-info-card h3 {
    color: var(--text-primary);
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
}

.product-info-card p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Forms & Inputs (Autofill Fix) */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #1e293b inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Login specific */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-container {
    background: rgba(15, 23, 42, 0.7);
    padding: 3rem 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.login-header {
    margin-bottom: 2.5rem;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-color), #3b82f6);
    -webkit-background-clip: text;
    color: transparent;
    text-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.login-header h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group input {
    margin-bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.05);
}

.input-group input:focus {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--accent-color);
}

.full-width {
    width: 100%;
}

.login-btn {
    padding: 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 1rem;
    letter-spacing: 0.5px;
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--text-primary);
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    header nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    .barcode-result-area {
        grid-template-columns: 1fr;
    }
    .model-section h2 {
        font-size: 2rem;
    }
}
