/* ===================================================
   BarcodeHub Pro - Jain Software Branded Light Theme
   =================================================== */

:root {
    /* Jain Software Brand Colors */
    --primary: #8B1A1A;
    --primary-light: #A82828;
    --primary-dark: #6B1010;
    --primary-glow: rgba(139, 26, 26, 0.15);

    /* Secondary / Accent - Jain Software Indigo */
    --secondary: #2D2B55;
    --secondary-light: #3D3A70;
    --secondary-dark: #1E1C3A;

    /* Accent Colors */
    --accent-blue: #3B5998;
    --accent-cyan: #0891B2;
    --accent-green: #16A34A;
    --accent-orange: #EA580C;
    --accent-red: #DC2626;
    --accent-pink: #DB2777;

    /* Light Theme */
    --bg-primary: #F8F9FC;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F1F3F8;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F6F7FB;
    --bg-input: #F5F6FA;
    --bg-modal: rgba(45, 43, 85, 0.5);

    /* Sidebar specific */
    --sidebar-bg: #2D2B55;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(139, 26, 26, 0.25);
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-active: #FFFFFF;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    /* Text */
    --text-primary: #1A1A2E;
    --text-secondary: #4A4A6A;
    --text-muted: #8888A8;
    --text-accent: #8B1A1A;

    /* Borders */
    --border-primary: rgba(139, 26, 26, 0.15);
    --border-secondary: #E8EAF0;
    --border-input: #D0D4E0;

    /* Sizing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.05);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #C0C4D0;
    border-radius: 3px;
}

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

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.required {
    color: var(--accent-red);
}

code {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: var(--primary);
    border: 1px solid var(--border-secondary);
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2D2B55 0%, #1E1C3A 40%, #8B1A1A 100%);
    position: relative;
    overflow: hidden;
}

.login-bg-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.floating-barcode {
    position: absolute;
    width: 3px;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    opacity: 0.2;
    animation: floatUp 8s linear infinite;
}

.fb-1 {
    left: 10%;
    height: 120px;
    animation-delay: 0s;
    animation-duration: 7s;
}

.fb-2 {
    left: 25%;
    height: 80px;
    animation-delay: 1.5s;
    animation-duration: 9s;
}

.fb-3 {
    left: 50%;
    height: 150px;
    animation-delay: 3s;
    animation-duration: 6s;
}

.fb-4 {
    left: 70%;
    height: 100px;
    animation-delay: 0.5s;
    animation-duration: 8s;
}

.fb-5 {
    left: 85%;
    height: 90px;
    animation-delay: 2s;
    animation-duration: 10s;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.2;
    }

    90% {
        opacity: 0.2;
    }

    100% {
        transform: translateY(-200px) rotate(10deg);
        opacity: 0;
    }
}

.login-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 440px;
    padding: 48px 40px;
    background: #FFFFFF;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    animation: cardAppear 0.6s ease-out;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.logo-icon img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: -0.5px;
}

.login-logo h1 .brand-jain {
    color: var(--primary);
}

.pro-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    vertical-align: super;
    letter-spacing: 1px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-secondary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
}

.input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #FFFFFF;
}

.input-wrapper input:focus~.input-icon {
    color: var(--primary);
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}

.toggle-password:hover {
    color: var(--text-primary);
}

.login-error {
    padding: 10px 14px;
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--border-radius-sm);
    color: var(--accent-red);
    font-size: 0.85rem;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.5s ease;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-secondary);
}

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

.login-footer .powered-by {
    margin-top: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.login-footer .powered-by a {
    color: var(--primary);
    font-weight: 600;
}

/* ===== APP SCREEN ===== */
.app-screen {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR (Dark branded) ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: all var(--transition-normal);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.sidebar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #FFFFFF;
}

.sidebar-brand .brand-jain {
    color: #FF6B6B;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover);
    color: #FFFFFF;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #FFFFFF;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #FFFFFF;
    border: 1px solid rgba(139, 26, 26, 0.3);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary-light);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #FFFFFF;
}

.user-role {
    font-size: 0.7rem;
    color: var(--sidebar-text);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: rgba(220, 38, 38, 0.2);
    color: #FF6B6B;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
    background: var(--bg-primary);
}

/* ===== TOPBAR ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    padding: 8px 12px 8px 38px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-secondary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 260px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    width: 300px;
    background: #FFFFFF;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    position: relative;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.notification-wrapper {
    position: relative;
}

.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    border: 2px solid #FFFFFF;
    display: none;
}

.notif-dot.visible {
    display: block;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-height: 420px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

.notif-dropdown.open {
    display: block;
    animation: fadeIn 0.2s ease;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-primary);
}

.notif-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-clear-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.notif-clear-btn:hover {
    text-decoration: underline;
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-secondary);
    cursor: default;
    transition: background 0.15s;
}

.notif-item:hover {
    background: var(--bg-secondary);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.notif-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.notif-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.notif-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.notif-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.notif-icon.purple {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.notif-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.notif-empty {
    padding: 30px 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

/* ===== PAGE CONTAINER ===== */
.page-container {
    padding: 24px;
}

.page {
    display: none;
    animation: pageIn 0.3s ease-out;
}

.page.active {
    display: block;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-normal);
    cursor: default;
    box-shadow: var(--shadow-card);
}

.stat-card:hover {
    border-color: var(--border-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue {
    background: rgba(59, 89, 152, 0.1);
    color: var(--accent-blue);
}

.stat-icon-purple {
    background: rgba(139, 26, 26, 0.08);
    color: var(--primary);
}

.stat-icon-green {
    background: rgba(22, 163, 74, 0.1);
    color: var(--accent-green);
}

.stat-icon-orange {
    background: rgba(234, 88, 12, 0.1);
    color: var(--accent-orange);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--secondary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: border-color var(--transition-fast);
    box-shadow: var(--shadow-card);
}

.card:hover {
    border-color: var(--border-primary);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-secondary);
    background: var(--bg-tertiary);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--secondary);
}

.card-body {
    padding: 20px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-secondary);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: rgba(220, 38, 38, 0.08);
    color: var(--accent-red);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.15);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== INPUTS (non-login) ===== */
.page input[type="text"],
.page input[type="number"],
.page input[type="password"],
.page select,
.page textarea,
.modal input[type="text"],
.modal input[type="number"],
.modal input[type="password"],
.modal select,
.modal textarea {
    padding: 10px 14px;
    background: #FFFFFF;
    border: 1.5px solid var(--border-secondary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: all var(--transition-fast);
    width: 100%;
}

.page input:focus,
.page select:focus,
.page textarea:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.page select,
.modal select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888A8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    background-color: #FFFFFF;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.full-width {
    grid-column: 1 / -1;
}

/* ===== CHECKBOX ===== */
.checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.checkbox-label:hover {
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ===== FORMAT TABS ===== */
.format-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 16px;
    overflow-x: auto;
    border: 1px solid var(--border-secondary);
}

.format-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.format-tab:hover {
    background: #FFFFFF;
    color: var(--text-primary);
}

.format-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* ===== FORMAT GRID ===== */
.format-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.format-option {
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-secondary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.format-option:hover {
    border-color: var(--primary);
    background: rgba(139, 26, 26, 0.03);
}

.format-option.selected {
    border-color: var(--primary);
    background: rgba(139, 26, 26, 0.06);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.format-option .format-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.format-option .format-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ===== GENERATE LAYOUT ===== */
.generate-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.generate-form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.generate-preview-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sticky-preview {
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
}

.generate-btn {
    font-size: 1.05rem;
    padding: 16px;
}

/* ===== BARCODE PREVIEW ===== */
.barcode-preview-area {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #FAFBFE;
    border-radius: var(--border-radius-sm);
}

.barcode-preview-area canvas,
.barcode-preview-area svg,
.barcode-preview-area img {
    max-width: 100%;
    height: auto;
}

.barcode-display {
    text-align: center;
    width: 100%;
}

.barcode-display .barcode-label {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.barcode-display .barcode-format-tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(139, 26, 26, 0.08);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 6px;
    letter-spacing: 0.5px;
    border: 1px solid rgba(139, 26, 26, 0.15);
}

/* All Formats Grid */
.all-formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.format-preview-item {
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius-sm);
    text-align: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.format-preview-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.format-preview-item canvas,
.format-preview-item svg,
.format-preview-item img {
    max-width: 100%;
    height: auto;
    max-height: 100px;
}

.format-preview-item .format-label {
    margin-top: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.25;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.empty-state.small {
    padding: 24px 16px;
}

.empty-state.small svg {
    margin-bottom: 8px;
}

.empty-state.small p {
    font-size: 0.85rem;
    margin-bottom: 0;
}

/* ===== RECENT LIST ===== */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-secondary);
    transition: all var(--transition-fast);
}

.recent-item:hover {
    border-color: var(--border-primary);
    box-shadow: var(--shadow-sm);
}

.recent-item-left {
    display: flex;
    flex-direction: column;
}

.recent-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.recent-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-item-actions {
    display: flex;
    gap: 6px;
}

.recent-item-actions .btn-sm {
    padding: 4px 10px;
}

/* ===== QUICK GENERATE ===== */
.quick-gen-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===== TABLE ===== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-secondary);
    font-size: 0.85rem;
}

.data-table th {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
}

.data-table td .product-name {
    font-weight: 600;
    color: var(--secondary);
}

.data-table td .variant-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(139, 26, 26, 0.06);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(139, 26, 26, 0.12);
}

.data-table td .category-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(22, 163, 74, 0.08);
    color: var(--accent-green);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(22, 163, 74, 0.15);
}

.action-btns {
    display: flex;
    gap: 4px;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.action-btn.delete:hover {
    background: rgba(220, 38, 38, 0.08);
    color: var(--accent-red);
}

/* ===== PAGE ACTIONS ===== */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-actions-left,
.page-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-filter {
    position: relative;
    display: flex;
    align-items: center;
}

.search-filter svg {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-filter input {
    padding-left: 38px !important;
    width: 280px;
}

.filter-select {
    min-width: 160px;
}

/* ===== PRINT PAGE ===== */
.print-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    align-items: start;
}

.print-settings-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.print-preview-section {
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
}

.print-preview-body {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.print-preview-area {
    min-height: 400px;
    background: white;
    border-radius: var(--border-radius-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border-secondary);
}

.print-preview-area .empty-state {
    color: #9CA3AF;
}

.print-page {
    width: 100%;
    background: white;
    padding: 10mm;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
}

.print-label-row {
    display: flex;
    gap: 4mm;
    margin-bottom: 4mm;
    justify-content: flex-start;
}

.print-label {
    border: 1px dashed #ddd;
    padding: 3mm;
    text-align: center;
    flex: 1;
    max-width: calc(100% / var(--labels-per-row));
    box-sizing: border-box;
}

.print-label .label-name {
    font-size: 8px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.print-label .label-barcode canvas,
.print-label .label-barcode svg {
    max-width: 100%;
    height: auto;
}

.print-label .label-price {
    font-size: 9px;
    font-weight: 700;
    color: #111;
    margin-top: 2px;
}

.print-label .label-sku {
    font-size: 6px;
    color: #666;
}

.print-label .label-mrp {
    font-size: 7px;
    color: #555;
}

.print-label .label-brand {
    font-size: 7px;
    color: #444;
    font-style: italic;
}

/* ===== PRINT PRODUCT LIST ===== */
.print-product-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.print-product-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.print-product-item:hover {
    border-color: var(--border-primary);
}

.print-product-item.selected {
    border-color: var(--primary);
    background: rgba(139, 26, 26, 0.08);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.print-product-item .ppi-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.print-product-item .ppi-code {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ===== SETTINGS ===== */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.settings-grid .full-width {
    grid-column: 1 / -1;
}

.data-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    width: 100%;
    max-width: 600px;
    background: #FFFFFF;
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-secondary);
    background: var(--bg-tertiary);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-secondary);
    background: var(--bg-tertiary);
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #FFFFFF;
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: toastIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast.success::before {
    background: var(--accent-green);
}

.toast.error::before {
    background: var(--accent-red);
}

.toast.info::before {
    background: var(--accent-blue);
}

.toast.warning::before {
    background: var(--accent-orange);
}

.toast-icon {
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--accent-green);
}

.toast.error .toast-icon {
    color: var(--accent-red);
}

.toast.info .toast-icon {
    color: var(--accent-blue);
}

.toast.warning .toast-icon {
    color: var(--accent-orange);
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ===== JAIN SOFTWARE WATERMARK ===== */
.jain-watermark {
    position: fixed;
    bottom: 16px;
    right: 24px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.jain-watermark img {
    width: 16px;
    height: 16px;
}

.jain-watermark a {
    color: var(--primary);
    font-weight: 600;
}

/* ===== PRINT AREA (hidden offscreen, used for actual printing) ===== */
.print-area {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 100%;
    overflow: hidden;
    height: 0;
}

@media print {
    body * {
        visibility: hidden;
    }

    .print-area,
    .print-area * {
        visibility: visible !important;
    }

    .print-area {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .print-area .print-page {
        page-break-after: always;
        box-shadow: none;
        padding: 5mm;
    }

    .print-area .print-label {
        border: 1px dashed #ccc;
    }

    /* Ensure barcode images render in print */
    .print-area img,
    .print-area canvas {
        visibility: visible !important;
        display: block !important;
        max-width: 100% !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-area .label-barcode {
        visibility: visible !important;
        display: block !important;
    }

    .print-area .print-label-row {
        display: flex !important;
        flex-wrap: nowrap !important;
    }

    /* Single barcode printing mode */
    body.printing-barcode #mainBarcodeDisplay,
    body.printing-barcode #mainBarcodeDisplay * {
        visibility: visible !important;
    }

    body.printing-barcode #mainBarcodeDisplay {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        text-align: center !important;
        padding: 20px !important;
    }

    body.printing-barcode #mainBarcodeDisplay img,
    body.printing-barcode #mainBarcodeDisplay canvas {
        display: block !important;
        visibility: visible !important;
        margin: 0 auto !important;
        max-width: 100% !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Print Labels mode */
    body.printing-labels .print-area,
    body.printing-labels .print-area * {
        visibility: visible !important;
    }

    body.printing-labels .print-area {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    body.printing-labels .print-area img {
        display: block !important;
        max-width: 100% !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .generate-layout {
        grid-template-columns: 1fr;
    }

    .sticky-preview {
        position: static;
    }

    .print-layout {
        grid-template-columns: 1fr;
    }

    .print-preview-section {
        position: static;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .search-box input {
        width: 160px;
    }

    .search-box input:focus {
        width: 200px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions-left,
    .page-actions-right {
        flex-wrap: wrap;
    }

    .search-filter input {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }

    .format-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== LOADING SPINNER ===== */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}