/* === GLOBAL === */
body {
    background: #0f1319;
    color: #e0e0e0;
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    padding: 30px 20px 40px;
    box-sizing: border-box;
}

.left-stack {
    flex: 0 0 auto;
    width: min(720px, calc(100% - 384px));
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 320px;
}

.app-header {
    width: 95%;
    background: #1d222b;
    border: 1px solid #2c3341;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.app-header h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

.app-subtitle {
    margin: 0;
    color: #a0a7b3;
    font-size: 14px;
}

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

.primary-btn,
.secondary-btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.primary-btn {
    background: #4b8bf5;
    color: #fff;
}

.secondary-btn {
    background: #2e3443;
    color: #d3d8e2;
}

.primary-btn:hover {
    background: #74a6ff;
}

.secondary-btn:hover {
    background: #3b4254;
}

.app-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 24px;
    align-items: stretch;
    flex-wrap: nowrap;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100%;
}

.section {
    background: #1d222b;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid #2c3341;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

.section h3 {
    margin: 0 0 10px;
    color: #7ab3ff;
    font-size: 16px;
}

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

.section-header h3 {
    margin: 0;
}

.clear-btn {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #2f2f2f;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
}

.clear-btn:hover {
    background: #4b8bf5;
    color: #fff;
}

.section input,
.section select {
    width: 100%;
    margin-bottom: 10px;
    padding: 9px;
    border-radius: 6px;
    border: 1px solid #3a4355;
    background: #12161d;
    color: #e5e9f4;
    font-size: 15px;
    box-sizing: border-box;
}

/* BUTTON */
#getRatesBtn {
    background: #4b8bf5;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-size: 16px;
    font-weight: 600;
    transition: 0.2s ease;
}

#getRatesBtn:hover {
    background: #6ea4ff;
}

/* RIGHT SIDE (results panel) */
.right-column {
    flex: 0 0 360px;
    min-width: 320px;
    background: #1d222b;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid #2c3341;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    align-self: stretch;
    display: flex;
    flex-direction: column;
}

.right-column h3 {
    margin-top: 0;
    font-size: 17px;
    color: #b6d3ff;
}

#ratesOutput {
    margin-top: 12px;
    padding: 12px;
    background: #12161d;
    border-radius: 8px;
    border: 1px solid #2c3341;
    min-height: 250px;
    font-size: 15px;
    flex: 1;
}

/* Remove arrows (Chrome, Edge, Safari) */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Remove arrows (Firefox) */
input[type=number] {
    -moz-appearance: textfield;
}

/* Toggle switch */
.unitToggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 22px;
}

.unitToggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    border-radius: 22px;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
}

/* Checked (imperial) */
.unitToggle input:checked + .slider {
    background-color: #4b8bf5;
}

.unitToggle input:checked + .slider:before {
    transform: translateX(22px);
}

.package-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.unit-switch-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#unitMetric,
#unitImperial {
    font-size: 13px;
    color: #aaa;
}

#unitMetric.active,
#unitImperial.active {
    color: #6ea4ff;
    font-weight: 600;
}

/* Labels for inputs placed outside the fields */
.field-label {
    display: block;
    margin: 6px 0 6px 6px;
    color: #bfc6cc;
    font-size: 13px;
}

.section input[type="number"] {
    padding: 8px;
}

.package-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.package-field input[type="number"] {
    width: 100%;
    padding: 7px;
}

/* Address book small button and popup */
.address-book {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: -2px;
}

.address-book select {
    flex: 1;
}

.small-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #444c5a;
    background: #2f2f2f;
    color: #ccc;
    cursor: pointer;
}

.small-btn:hover {
    background: #4b8bf5;
    color: #fff;
}

.small-btn.danger {
    border-color: #7f1d1d;
    color: #ffb4b4;
}

.small-btn.danger:hover {
    background: #d64545;
}

.address-book-actions {
    display: flex;
    gap: 6px;
}

/* Popup */
.address-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-content {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    border: 1px solid #555;
}

.popup-content input {
    width: 100%;
    margin-bottom: 10px;
    padding: 6px;
    background: #1c1c1c;
    border: 1px solid #444;
    border-radius: 4px;
}

.popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.popup-save,
.popup-main,
.popup-cancel {
    padding: 6px 10px;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    flex: 1;
}

.popup-save {
    background: #4b8bf5;
    color: #fff;
}

.popup-main {
    background: #ffa500;
    color: #fff;
    font-weight: bold;
}

.popup-cancel {
    background: #555;
    color: #eee;
}

/* Address suggestions dropdown */
.suggestions {
    position: absolute;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    max-height: 160px;
    overflow-y: auto;
    width: calc(100% - 8px);
    display: none;
    z-index: 1000;
}

.suggestion-item {
    padding: 8px;
    cursor: pointer;
    color: #ddd;
    border-bottom: 1px solid #333;
}

.suggestion-item:hover {
    background: #3b3b3b;
}

.street-row {
    display: flex;
    gap: 10px;
}

.street-row input {
    flex: 2;
    margin-bottom: 0;
}

.street-row select {
    flex: 1;
    margin-bottom: 0;
}

.street-row input,
.street-row select {
    height: 36px;
    padding: 7px 10px;
    box-sizing: border-box;
}

.street-row {
    margin-bottom: 12px;
}

.ship-from-details {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 6px;
    background: #1b1b1b;
    font-size: 13px;
    color: #ddd;
    line-height: 1.4;
}

.rateLine {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #2d2d2d;
}

.rateLine:last-child {
    border-bottom: none;
}

.rateLine button {
    background: #2f2f2f;
    border: 1px solid #4b8bf5;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.rateLine button:hover {
    background: #4b8bf5;
    color: #fff;
}

.warn-text {
    color: #f4a261;
}

.error-text {
    color: #f66;
}

.ship-to-section {
    position: relative;
}

@media (max-width: 1100px) {
    .app-content {
        flex-wrap: wrap;
    }

    .left-stack,
    .right-column {
        width: 100%;
        max-width: 100%;
    }

    .right-column {
        flex: 1 1 auto;
        align-self: auto;
    }
}

@media (max-width: 900px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .app-content {
        flex-direction: column;
    }
}
