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

body {
    width: 400px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
}

.container {
    padding: 20px;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 20px;
    color: #333;
    margin: 0;
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

/* Dark Mode Styles */
body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .input-section,
body.dark-mode .result-section,
body.dark-mode .history-section {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #404040;
}

body.dark-mode h1,
body.dark-mode h3 {
    color: #e0e0e0;
}

body.dark-mode .input-group label {
    color: #d0d0d0;
}

body.dark-mode .input-group input,
body.dark-mode .input-group select {
    background: #1a1a1a;
    border-color: #404040;
    color: #e0e0e0;
}

body.dark-mode .input-group input:focus,
body.dark-mode .input-group select:focus {
    border-color: #007BFF;
}

body.dark-mode .options-section {
    background: #252525;
    border-color: #404040;
}

body.dark-mode .options-header {
    color: #d0d0d0;
}

body.dark-mode .barcode-hint {
    background: #2a3a4a;
    color: #b0d4ff;
    border-left-color: #007BFF;
}

body.dark-mode .btn-icon {
    background: #2d2d2d;
    border-color: #404040;
    color: #e0e0e0;
}

body.dark-mode .btn-icon:hover {
    background: #3d3d3d;
}

body.dark-mode .error-message {
    background: #4a2a2a;
    color: #ffaaaa;
    border-color: #6a4040;
}

body.dark-mode .success-message {
    background: #2a4a2a;
    color: #aaffaa;
    border-color: #4a6a4a;
}

.input-section {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #007BFF;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
    background-color: #007BFF;
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    flex: 1;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-generate {
    flex: 2;
    background-color: #28a745;
    color: white;
    padding: 12px;
    font-size: 16px;
}

.btn-generate:hover {
    background-color: #218838;
}

.btn-success {
    background-color: #17a2b8;
    color: white;
    flex: 1;
}

.btn-success:hover {
    background-color: #138496;
}

.btn-info {
    background-color: #ffc107;
    color: #333;
    flex: 1;
}

.btn-info:hover {
    background-color: #e0a800;
}

.result-section {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

#barcodeCanvas {
    max-width: 100%;
    height: auto;
    margin-bottom: 15px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #f5c6cb;
    font-size: 14px;
    text-align: center;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #c3e6cb;
    font-size: 12px;
    text-align: center;
    margin-top: 10px;
}

.barcode-hint {
    background: #e7f3ff;
    color: #004085;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #007BFF;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.4;
}

.input-group input:invalid {
    border-color: #dc3545;
}

.input-group input:valid {
    border-color: #28a745;
}

.options-section {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin-top: 15px;
    margin-bottom: 15px;
}

.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    margin-bottom: 10px;
    cursor: pointer;
}

.btn-toggle {
    background: none;
    border: none;
    font-size: 12px;
    color: #6c757d;
    cursor: pointer;
    padding: 2px 8px;
    transition: transform 0.3s;
}

.btn-toggle:hover {
    color: #495057;
}

.options-content {
    display: grid;
    gap: 12px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.option-row label {
    flex: 1;
    font-size: 13px;
    color: #495057;
    margin: 0;
    min-width: 120px;
}

.option-row input[type="range"] {
    flex: 2;
    margin: 0;
}

.option-row input[type="color"] {
    width: 50px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.option-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#scaleValue {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: #007BFF;
}

.options-content.collapsed {
    display: none;
}

/* History Section */
.history-section {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.history-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.history-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    cursor: pointer;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.history-item canvas {
    width: 100px;
    height: auto;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-type {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    margin-bottom: 4px;
}

.history-item-text {
    font-size: 12px;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-time {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 4px;
}

.history-item-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #007BFF;
    color: white;
}

.history-item-btn:hover {
    background: #0056b3;
}

.history-item-btn.delete {
    background: #dc3545;
}

.history-item-btn.delete:hover {
    background: #c82333;
}

body.dark-mode .history-section {
    background: #2d2d2d;
}

body.dark-mode .history-header {
    border-bottom-color: #404040;
}

body.dark-mode .history-header h3 {
    color: #e0e0e0;
}

body.dark-mode .history-item {
    background: #252525;
    border-color: #404040;
}

body.dark-mode .history-item:hover {
    background: #303030;
}

body.dark-mode .history-item canvas {
    border-color: #404040;
}

body.dark-mode .history-item-type {
    color: #d0d0d0;
}

body.dark-mode .history-item-text {
    color: #a0a0a0;
}

body.dark-mode .history-item-time {
    color: #707070;
}