* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --info: #4299e1;
    --light: #f8fafc;
    --dark: #2d3748;
    --gray: #718096;
    --gray-light: #e2e8f0;
    --border-radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.barcode-app {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.app-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.app-header p {
    opacity: 0.9;
    font-weight: 300;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--light);
    border-bottom: 1px solid var(--gray-light);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 20px;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: white;
    color: var(--primary);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    min-height: 500px;
}

.tab-content.active {
    display: block;
}

/* Generator */
.generator-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
}

.input-section {
    background: var(--light);
    padding: 25px;
    border-radius: var(--border-radius);
}

.input-section h3 {
    margin-bottom: 20px;
    color: var(--dark);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.counter {
    text-align: right;
    font-size: 0.9rem;
    color: var(--gray);
    margin-top: 5px;
}

.generate-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Preview */
.preview-section {
    background: var(--light);
    padding: 25px;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
}

.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#barcodePreview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    border: 2px dashed var(--gray-light);
    min-height: 300px;
}

.placeholder {
    text-align: center;
    color: var(--gray);
}

.placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

#barcodePreview canvas,
#barcodePreview svg {
    max-width: 100%;
    max-height: 300px;
}

.preview-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.download-btn, .save-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.download-btn {
    background: var(--success);
    color: white;
}

.download-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
}

.save-btn {
    background: var(--info);
    color: white;
}

.save-btn:hover:not(:disabled) {
    background: #3182ce;
    transform: translateY(-2px);
}

.download-btn:disabled, .save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Batch */
.batch-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
}

.batch-input {
    background: var(--light);
    padding: 25px;
    border-radius: var(--border-radius);
}

.batch-output {
    background: var(--light);
    padding: 25px;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.batch-header h4 {
    color: var(--dark);
}

.download-all-btn {
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.download-all-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
}

.download-all-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.batch-results {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    align-content: start;
}

.batch-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--gray-light);
}

.batch-item canvas,
.batch-item svg {
    max-width: 100%;
    max-height: 80px;
    margin-bottom: 8px;
}

.batch-item-label {
    font-size: 0.8rem;
    color: var(--gray);
    word-break: break-all;
}

/* History */
.history-container {
    background: var(--light);
    border-radius: var(--border-radius);
    padding: 25px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-actions {
    display: flex;
    gap: 10px;
}

.export-btn, .clear-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.export-btn {
    background: var(--success);
    color: white;
}

.export-btn:hover {
    background: #38a169;
}

.clear-btn {
    background: var(--danger);
    color: white;
}

.clear-btn:hover {
    background: #e53e3e;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    color: var(--gray);
    padding: 40px 20px;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.history-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-left: 4px solid var(--primary);
}

.history-barcode {
    width: 80px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--gray-light);
    border-radius: 6px;
}

.history-barcode canvas,
.history-barcode svg {
    max-width: 100%;
    max-height: 100%;
}

.history-details {
    flex: 1;
}

.history-data {
    font-weight: 600;
    margin-bottom: 5px;
}

.history-meta {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: var(--gray);
}

.history-type {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.copy-btn, .delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: var(--gray);
}

.copy-btn:hover {
    background: var(--info);
    color: white;
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .app-header {
        padding: 20px;
    }
    
    .tab-content {
        padding: 20px;
    }
    
    .generator-container,
    .batch-container {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}