/* Reset và Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.125rem;
    color: #6b7280;
}

/* Steps */
.step {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin-bottom: 2rem;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #4f46e5;
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 1.25rem;
}

.step-header h2 {
    font-size: 1.5rem;
    color: #111827;
}

/* Input Section */
.format-guide {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.format-guide h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #374151;
}

.format-guide ul {
    list-style: none;
}

.format-guide li {
    padding: 0.5rem 0;
    color: #4b5563;
}

.format-guide code {
    background: #e5e7eb;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* Textarea */
.textarea-wrapper {
    margin-bottom: 1.5rem;
}

#productInput {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s;
}

#productInput:focus {
    outline: none;
    border-color: #4f46e5;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

/* Create button specific */
#createProductsBtn {
    background: #10b981;
}

#createProductsBtn:hover:not(:disabled) {
    background: #059669;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon.existing {
    background: #dbeafe;
    color: #2563eb;
}

.card-icon.new {
    background: #d1fae5;
    color: #059669;
}

.card-icon.total {
    background: #fef3c7;
    color: #d97706;
}

.card-content {
    display: flex;
    flex-direction: column;
}

.card-label {
    font-size: 0.875rem;
    color: #6b7280;
}

.card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #111827;
}

/* Tables */
.results-tables {
    display: grid;
    grid-template-columns: 40% 60%; /* 40% cho đã có, 60% cho mới */
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.table-section h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: #374151;
}

.table-wrapper {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

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

thead {
    background: #f3f4f6;
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #e5e7eb;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f3f4f6;
}

/* Table layout cho sản phẩm mới */
#newProductsTable {
    table-layout: fixed;
    width: 100%;
}

#newProductsTable th:nth-child(1) { width: 50px; }   /* STT */
#newProductsTable th:nth-child(2) { width: 100px; }  /* Mã SP */
#newProductsTable th:nth-child(3) { width: 80px; }   /* Số lượng */
#newProductsTable th:nth-child(4) { width: 110px; }  /* Giá nhập */
#newProductsTable th:nth-child(5) { width: 110px; }  /* Giá bán */
#newProductsTable th:nth-child(6) { width: auto; }   /* Trạng thái */

#newProductsTable td {
    padding: 0.5rem;
    vertical-align: middle;
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: #9ca3af;
}

/* Price Input Fields */
.price-input {
    width: 100%;
    max-width: 100px;
    padding: 0.4rem 0.6rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.875rem;
    text-align: right;
    font-family: monospace;
    transition: all 0.2s;
}

.price-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.price-input.error {
    border-color: #ef4444;
    background-color: #fee2e2;
}

.price-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Apply All Controls */
.apply-all-controls {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.apply-all-controls h4 {
    margin-bottom: 0.75rem;
    color: #374151;
    font-size: 0.95rem;
}

.apply-all-inputs {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.input-group {
    flex: 1;
    min-width: 120px;
}

.input-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.813rem;
    color: #6b7280;
}

#applyAllBtn {
    flex-shrink: 0;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f4f6;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.125rem;
}

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

/* Progress Dialog */
.progress-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.progress-dialog {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.progress-dialog h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: #111827;
}

.progress-info {
    margin-bottom: 1rem;
    color: #6b7280;
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-fill {
    height: 100%;
    background: #4f46e5;
    transition: width 0.3s ease;
}

.progress-results {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.success-count {
    color: #059669;
    font-weight: 600;
}

.error-count {
    color: #dc2626;
    font-weight: 600;
}

.error-details {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.error-details h4 {
    color: #dc2626;
    margin-bottom: 0.5rem;
}

.error-details p {
    color: #7f1d1d;
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

/* Status Badges */
.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.status.pending {
    background: #fef3c7;
    color: #92400e;
}

.status.valid {
    background: #dbeafe;
    color: #1e40af;
}

.status.success {
    background: #d1fae5;
    color: #065f46;
}

.status.error {
    background: #fee2e2;
    color: #991b1b;
}

/* Status cell adjustments */
.status-cell {
    vertical-align: middle;
}

.status-cell small {
    display: block;
    color: #dc2626;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .results-tables {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .results-tables {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

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

    .apply-all-inputs {
        flex-direction: column;
    }
    
    .input-group {
        width: 100%;
    }
    
    #applyAllBtn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .progress-dialog {
        min-width: 90%;
        margin: 1rem;
    }
    
    #newProductsTable {
        font-size: 0.75rem;
    }
    
    #newProductsTable th,
    #newProductsTable td {
        padding: 0.4rem 0.25rem;
    }
    
    .price-input {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
    }

    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

/* Table wrapper scrollable on mobile */
@media (max-width: 640px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #newProductsTable {
        min-width: 600px;
    }
}
/* Apply method selector */
.apply-method-selector {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.apply-method-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: #374151;
}

.apply-method-selector input[type="radio"] {
    cursor: pointer;
}

/* Apply sections */
.apply-section {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Range form - Inline compact style */
.range-form {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
}

.range-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.input-group.range {
    flex: 0 0 auto;
}

.input-group.price {
    flex: 1;
    min-width: 120px;
}

.input-group label {
    font-size: 0.813rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.range-input {
    width: 70px;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
    text-align: center;
}

.range-divider {
    padding-bottom: 6px;
    color: #9ca3af;
    font-weight: 500;
    font-size: 1.125rem;
}

/* Compact button style */
.btn-compact {
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    white-space: nowrap;
    align-self: flex-end;
}

.btn-compact .arrow-icon {
    width: 16px;
    height: 16px;
}

.example-text {
    font-size: 0.75rem;
    color: #6b7280;
    font-style: italic;
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .apply-method-selector {
        flex-direction: column;
        gap: 1rem;
    }
    
    .range-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .range-input {
        width: 100%;
    }
    
    .input-group.price {
        width: 100%;
    }
    
    .range-divider {
        display: none;
    }
    
    .btn-compact {
        width: 100%;
        justify-content: center;
    }
}

/* Import Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.modal-content.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: #6b7280;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #111827;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 200px);
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* Import Summary */
.import-summary {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.import-summary p {
    margin: 0;
    color: #374151;
    font-size: 0.95rem;
}

.import-summary strong {
    color: #111827;
    font-weight: 600;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
    font-size: 0.95rem;
}

.form-group .required {
    color: #ef4444;
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    background-color: white;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-select:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Import Progress */
.import-progress {
    text-align: center;
    padding: 2rem;
}

.import-progress h3 {
    margin: 1rem 0 0.5rem;
    font-size: 1.25rem;
    color: #111827;
}

.import-progress p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Success Modal Styles */
.success-icon {
    margin-bottom: 1.5rem;
}

.success-title {
    font-size: 1.5rem;
    color: #111827;
    margin-bottom: 1rem;
}

.success-details {
    background: #f9fafb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.success-details p {
    margin: 0.5rem 0;
    color: #374151;
}

.success-details strong {
    color: #111827;
}

.success-warning {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.success-warning p {
    color: #92400e;
    margin: 0;
    font-size: 0.875rem;
}

.text-center {
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Responsive */
@media (max-width: 640px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
        padding: 1rem;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}