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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.5rem;
    font-weight: 300;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: start;
}

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

.results-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.calculation-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.shipping-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.section-card {
    background: white;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.section-card h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.0rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 4px;
}

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

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

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

.input-group input:focus {
    outline: none;
    border-color: #3498db;
}

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

.input-group select:focus {
    outline: none;
    border-color: #3498db;
}

.input-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s ease;
    resize: vertical;
}

.input-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.format-info {
    margin-top: 8px;
    padding: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 12px;
    color: #495057;
    line-height: 1.4;
}

.example-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.example-link {
    display: block;
    padding: 6px 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    color: #495057;
    text-decoration: none;
    font-size: 12px;
    transition: all 0.2s ease;
}

.example-link:hover {
    background-color: #e9ecef;
    color: #333;
    text-decoration: none;
}

.unit-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.unit-group {
    display: flex;
    flex-direction: column;
}

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

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background-color: #27ae60;
    color: white;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    margin-bottom: 15px;
}

.btn-success:hover {
    background-color: #229954;
    transform: translateY(-2px);
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.list-container {
    min-height: 80px;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    background-color: #fafafa;
}

.list-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.list-item:hover {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.item-info {
    flex: 1;
}

.item-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.item-details {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.empty-message {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}

.results-container {
    background-color: #f8f9fa;
    border-radius: 5px;
    padding: 15px;
    border: 1px solid #e0e0e0;
}

.packing-result {
    background: white;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
}

.packing-result h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.packed-items {
    margin-left: 20px;
}

.packed-item {
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #555;
}

.packed-item small {
    color: #777;
    font-size: 12px;
}

.packing-visualization {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.packing-visualization h4 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
}

.packing-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.packing-link {
    margin-top: 15px;
    text-align: center;
}

.packing-link a {
    color: #3498db;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid #3498db;
    border-radius: 4px;
    display: inline-block;
    transition: all 0.3s ease;
}

.packing-link a:hover {
    background-color: #3498db;
    color: white;
}

.packing-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 2% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 95%;
    max-width: 1600px;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    background-color: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
}

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

.packing-step {
    background: white;
    border-radius: 6px;
    padding: 10px;
    border: 1px solid #dee2e6;
    text-align: center;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.packing-step:hover {
    background-color: #f0f8ff;
}

.packing-step .step-item {
    transition: all 0.3s ease;
}

.packing-step:hover .step-item.last-added {
    stroke-width: 4 !important;
    filter: drop-shadow(0 0 8px rgba(255, 107, 107, 0.8));
    animation: pulse-highlight 1s ease-in-out infinite alternate;
}

@keyframes pulse-highlight {
    0% { 
        transform: scale(1);
        opacity: 0.9;
    }
    100% { 
        transform: scale(1.05);
        opacity: 1;
    }
}

.step-header {
    font-size: 12px;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 500;
}

.step-diagram {
    display: flex;
    justify-content: center;
}

.step-diagram svg {
    max-width: 100%;
    height: auto;
}

.info-box {
    background-color: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 15px;
}

.info-box p {
    margin: 0;
    color: #2e7d32;
    font-weight: 500;
}

.shipping-rates {
    display: grid;
    gap: 1px;
    margin: 5px;
}

.shipping-rate {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0;
    transition: box-shadow 0.2s ease;
}

.shipping-rate:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.shipping-rate h4 {
    color: #2c3e50;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.shipping-rate p {
    margin: 0;
    color: #555;
    font-size: 0.8rem;
}

.shipping-rate p strong {
    color: #333;
}

.shipping-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.8rem;
}

.shipping-table th,
.shipping-table td {
    border: 1px solid #dee2e6;
    padding: 4px 6px;
    text-align: left;
}

.shipping-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.75rem;
}

.shipping-table .service-name {
    font-weight: 500;
    color: #2c3e50;
}

.shipping-table .cost-optimized {
    color: #27ae60;
    font-weight: 600;
}

.shipping-table .cost-individual {
    color: #6c757d;
}

.shipping-table .savings.positive {
    color: #27ae60;
    font-weight: 600;
}

.shipping-table .savings.negative {
    color: #e74c3c;
    font-weight: 600;
}

.table-note {
    font-size: 0.7rem;
    color: #6c757d;
    margin: 4px 0 0 0;
    font-style: italic;
}

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

.efficiency-info {
    background-color: #e8f5e8;
    border: 1px solid #c3e6c3;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
}

.efficiency-info strong {
    color: #27ae60;
}

.error-message {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    padding: 10px;
    color: #721c24;
    margin-top: 10px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading::after {
    content: "...";
    animation: loading 1s infinite;
}

@keyframes loading {
    0% { content: "..."; }
    33% { content: "..."; }
    66% { content: "..."; }
    100% { content: "..."; }
}



@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 15px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
}


/* Toggle Switch Styles */
.toggle-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 30px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2;
    pointer-events: none;
}

.toggle-input:checked + .toggle-slider {
    background-color: #27ae60;
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.toggle-text {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 10px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    pointer-events: none;
    position: relative;
    z-index: 0;
}

.toggle-on {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toggle-off {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.toggle-input:checked + .toggle-slider .toggle-on {
    opacity: 1;
}

.toggle-input:checked + .toggle-slider .toggle-off {
    opacity: 0;
}

.toggle-slider:hover {
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.toggle-input:focus + .toggle-slider {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 20px;
    }
    
    .section-card {
        padding: 12px;
    }
}