/* style.css */
:root {
    --primary-color: #000; /* A nice blue */
    --primary-hover: #202020;
    --secondary-color: #f3f4f6;
    --secondary-hover: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;
    --card-bg: #ffffff;
    --body-bg: #f9fafb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --font-family: 'Inter', sans-serif;
}
body {
    font-family: var(--font-family);
    background-color: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 2rem;
    font-size: 14px;
}
.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    /* Sizing & Positioning */
    max-width: fit-content; /* Makes the card only as wide as the content */
    margin: 0 auto 2rem auto; /* Centers the card horizontally and adds margin below */
    
    /* Styling copied from .card */
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem; /* A bit less padding for a tighter fit */
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.logo {
    max-width: 300px;
    height: auto;
}
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}
h2 {
    font-size: 1.5rem;
    margin-top: 0;
}
h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}
h4 {
    margin: 0 0 0.5rem 0;
}
p {
    color: var(--text-secondary);
    line-height: 1.5;
}
/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

select {
    /* Hide the default browser arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* Add our custom arrow */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3e%3cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd' /%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center; /* Position from the right edge */
    background-size: 1.25em;

    /* Add padding to prevent text from overlapping the arrow */
    padding-right: 2.5rem;
}

/* Input with Icon */
.input-with-icon {
    position: relative;
}
.input-with-icon input {
    padding-right: 2.5rem; /* Make space for the icon */
}
.paste-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.paste-icon:hover {
    opacity: 1;
}
/* Buttons */
.button-primary, .button-secondary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    font-size: 14px;
}
.button-primary {
    background-color: var(--primary-color);
    color: white;
}
.button-primary:hover {
    background-color: var(--primary-hover);
}
.button-primary:disabled {
    background-color: #93c5fd;
    cursor: not-allowed;
}
.button-secondary {
    background-color: var(--secondary-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.button-secondary:hover {
    background-color: var(--secondary-hover);
}
.full-width {
    width: 100%;
}
/* Layout */
#main-app {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
#main-app.centered-summary {
    grid-template-columns: 1fr;
    justify-items: center;
}
#main-app.centered-summary .column-right {
    width: 100%;
    max-width: 500px;
}
.column-right .sticky-card {
    position: sticky;
    top: 1.5rem;
}
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-package-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: center;
}
/* Packages List */
#packages-list {
    margin-top: 1.5rem;
}
.package-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--body-bg);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}
.package-item span { font-weight: 500; }
.remove-package-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
}
/* Summary */
hr { border: none; border-top: 1px solid var(--border-color); margin: 1.5rem 0; }
#summary-address-details {
    padding: 0.5rem 0;
}
.summary-line {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
    font-size: 13px;
    word-break: break-word;
}
.summary-line:first-child {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}
.summary-line:empty {
    display: none;
}
.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 14px;
}
.summary-item-warning {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 6px;
    background-color: #fffbeb;
    color: #b45309;
    font-weight: 500;
}
#rate-estimate {
    font-size: 1.2rem;
}
#success-message .prn-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f1ffef;
    border-radius: 6px;
    padding: 1rem;
}
#success-message #prn-number {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
}
#success-message .copy-icon {
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}
#success-message .copy-icon:hover {
    opacity: 1;
}
#success-message #final-cost {
    display: block;
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0.5rem 0 1rem 0;
    text-align: center;
    padding: 1rem;
    background: #f1ffef;
    border-radius: 6px;
}
/* Utility Classes */
.hidden { display: none !important; }
/* Spinner */
.spinner-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Notification */
#notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s, top 0.3s;
}
#notification.show {
    opacity: 1;
    top: 40px;
}
#notification.error { background-color: var(--error-color); }
#notification.success { background-color: var(--success-color); }
/* Responsive */
@media (max-width: 900px) {
    #main-app { grid-template-columns: 1fr; }
    .column-right .sticky-card { position: static; }
    #main-app.centered-summary .column-right {
        max-width: none;
    }
}
@media (max-width: 600px) {
    body { padding: 1rem; }
    .grid-2-col, .grid-3-col, .grid-package-form { grid-template-columns: 1fr; }
}

#api-key-section {
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
}

#address-details-wrapper {
    margin-top: 1.5rem;
}

/* --- /* --- Locator and Map Styles --- */
.header-top {
    max-width: fit-content;
    margin: 0 auto 2rem auto;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

#locator-section.card-grid {
    display: flex; /* Use Flexbox for alignment */
    gap: 1.5rem;
    align-items: stretch; /* This is the key to equal heights */
    margin-bottom: 2rem;
}

#locator-section.card-grid > .card {
    flex: 1; /* Make the left column take up half the space */
    display: flex;
    flex-direction: column;
}

#locator-section.card-grid > .locator-column {
    flex: 1; /* Make the right column take up the other half */
}

#locator-content {
    flex-grow: 1; /* Allows the content to expand and fill space */
}

.locator-column h3 {
    margin-bottom: 1.5rem;
}

#locator-content p {
    font-size: 14px;
    color: var(--text-secondary);
}

.visual-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.map-container {
    padding: 0.5rem;
    margin: 0;
    width: 300px;
    box-sizing: border-box;
    /* min-height is no longer needed as flexbox handles it */
}

/* This rule can be removed as the one below is more specific */
/*
.visual-column .map-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
*/

/* Apply hover effect only to the image's container */
.visual-column .map-container:has(#location-image-frame) {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.visual-column .map-container:has(#location-image-frame):hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}


#gmap-frame, #location-image-frame {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

#gmap-frame {
    background-color: #e5e7eb;
}

#location-image-frame {
    object-fit: cover;
}

#location-special-instructions {
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

/* Inline spinner for the locator card */
.spinner-inline {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 25px;
    height: 25px;
    animation: spin 1s linear infinite;
    margin: 1rem auto 0 auto;
}

@media (max-width: 900px) {
    #locator-section.card-grid, .visual-column { 
        flex-direction: column; /* Stack instead of side-by-side on mobile */
        grid-template-columns: 1fr; 
    }
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

#modal-body img, #modal-body .static-map {
    width: 100%;
    max-height: calc(90vh - 40px);
    display: block;
}

/* Make the image container clickable */

.visual-column .map-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#location-special-instructions {
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 0.75rem;
    padding: 0 0.5rem; /* Add some horizontal padding */
}

.no-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--secondary-color);
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
    border-radius: 6px;
    text-align: center;
}

/* --- Character Counter Styles --- */
.label-with-counter {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
}

.char-counter {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.char-counter.over-limit {
    color: var(--error-color);
    font-weight: 600;
}

.receipt-details {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #f9fafb; /* var(--body-bg) */
    border: 1px solid #d1d5db; /* var(--border-color) */
    border-radius: 6px;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.5rem 0;
    font-size: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.receipt-item:last-child {
    border-bottom: none;
}

.receipt-item span {
    color: #6b7280; /* var(--text-secondary) */
    padding-right: 1rem;
}

.receipt-item strong {
    text-align: right;
    word-break: break-word;
}