/* ==================================
   Base Variables & Resets
   ================================== */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);

    --bg-dark: #0f172a;
    --bg-light: #f8fafc;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #f8fafc;

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-light);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Abstract Background Shapes */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 20s infinite ease-in-out alternate;
}

.shape-1 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    bottom: -200px;
    right: -100px;
    animation-delay: -5s;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #f43f5e, #ec4899);
    top: 40%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(30px, 50px) rotate(15deg);
    }
}

/* ==================================
   Utility Classes
   ================================== */
.hidden {
    display: none !important;
}

.text-gradient {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.box-shadow-xl {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Glassmorphism */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 15px -3px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -5px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.lg {
    width: 100%;
    padding: 16px 32px;
    font-size: 1.1rem;
    border-radius: var(--border-radius-lg);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-main);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.8);
}

.icon-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

/* Forms */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: white;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1.25rem;
}

.input-wrapper input {
    padding-left: 48px;
}

.password-input {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input .icon-btn {
    position: absolute;
    right: 8px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.checkbox-group label {
    font-size: 0.95rem;
    cursor: pointer;
}

/* ==================================
   Login Screen
   ================================== */
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: var(--border-radius-lg);
    z-index: 10;
    animation: fadeIn 0.5s ease-out forwards;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header i {
    font-size: 4rem;
    margin-bottom: 16px;
}

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-header p.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.error-msg {
    color: #ef4444;
    font-size: 0.9rem;
    margin-bottom: 16px;
    text-align: center;
    display: none;
    animation: shake 0.4s ease-in-out;
}

.error-msg.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ==================================
   Main Application Layout
   ================================== */
.app-wrapper {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    z-index: 10;
    animation: fadeIn 0.5s ease-out forwards;
}

.app-header {
    border-radius: var(--border-radius-md);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 2rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo span {
    color: var(--text-muted);
    font-weight: 400;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 30px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.toggle-btn {
    padding: 8px 20px;
    border-radius: 26px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.toggle-btn:hover {
    color: var(--text-main);
}

.toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.toggle-btn i {
    font-size: 1.1rem;
}

.avatar {
    background: linear-gradient(135deg, var(--primary), #a855f7);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 1px;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
    /* Important for scrollable children */
}

/* Settings Panel */
.settings-panel {
    border-radius: var(--border-radius-lg);
    padding: 24px;
    overflow-y: auto;
}

.settings-panel::-webkit-scrollbar {
    width: 6px;
}

.settings-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.panel-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.panel-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.theme-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.theme-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid transparent;
    padding: 10px 0;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

.theme-btn.active {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.color-pickers {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.color-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.color-input-wrapper label {
    font-size: 0.8rem;
    text-align: center;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 100%;
    height: 40px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius-sm);
}

.file-upload {
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.5);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-upload:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.8);
}

.file-upload i {
    font-size: 2rem;
    color: var(--text-muted);
}

.file-upload span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.preview-header {
    text-align: center;
}

.preview-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.preview-header p {
    color: var(--text-muted);
    margin-top: 4px;
}

/* The Exportable QR Card Setup */
.preview-container {
    padding: 0;
    border-radius: var(--border-radius-lg);
    background: transparent;
    transition: var(--transition);
    width: 100%;
    display: flex;
    justify-content: center;
}

/* EAN-13 Grid setup */
.ean-grid-container {
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    width: 100%;
    height: 520px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.02);
}

.barcode-card {
    background: white;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.barcode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.15);
    border: 1px solid var(--primary);
}

.barcode-download-overlay {
    position: absolute;
    inset: 0;
    background: rgba(99, 102, 241, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: var(--border-radius-sm);
}

.barcode-download-overlay i {
    font-size: 1.8rem;
    color: white;
}

.barcode-download-overlay small {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.barcode-card:hover .barcode-download-overlay {
    opacity: 1;
}

.barcode-card img {
    width: 100%;
    height: auto;
}

.barcode-card span {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Card Themes */
.qr-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    min-height: 520px;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    /* Default fallback */
}

/* Common Card Content Styling */
.card-content {
    position: relative;
    z-index: 2;
    padding: 40px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.card-header {
    text-align: center;
    margin-bottom: 30px;
    width: 100%;
}

.brand-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 12px;
}

#previewTitle {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
    word-break: break-word;
}

#previewText {
    font-size: 1rem;
    color: #64748b;
}

.qr-wrapper {
    position: relative;
    background: white;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.qr-center-logo {
    position: absolute;
    width: 50px;
    height: 50px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

.card-footer {
    margin-top: 40px;
}

.secure-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
}

.secure-badge i {
    color: #10b981;
    font-size: 1.1rem;
}

/* Theme Variants */
.theme-modern {
    background: #ffffff;
}

.theme-modern .card-glass-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 160px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border-bottom-left-radius: 50% 20%;
    border-bottom-right-radius: 50% 20%;
    z-index: 1;
}

.theme-minimal {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    box-shadow: none;
}

.theme-minimal .card-glass-bg {
    display: none;
}

.theme-minimal .qr-wrapper {
    box-shadow: none;
    border: 1px dashed #cbd5e1;
}

.theme-dark {
    background: #0f172a;
    color: white;
}

.theme-dark .card-glass-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.2), transparent 50%);
    z-index: 1;
}

.theme-dark #previewTitle {
    color: white;
}

.theme-dark #previewText {
    color: #94a3b8;
}

.theme-dark .secure-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .app-wrapper {
        height: auto;
        min-height: 90vh;
        max-width: 100%;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .settings-panel {
        max-height: none;
        overflow: visible;
        /* Prevent double scrollbars on mobile */
    }

    .preview-panel {
        margin-top: 2rem;
    }
}

@media (max-width: 450px) {
    .login-container {
        padding: 30px 20px;
    }

    .card-content {
        padding: 24px;
    }

    .qr-card {
        min-height: 480px;
    }

    .app-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        text-align: center;
    }
}