/* ============================================
   Grace Logistics – Rate Search Styles
   Extends the main styles.css
   ============================================ */

/* ── Page Header ── */
.page-header-rates {
    background: linear-gradient(135deg, #0f2557 0%, #1e40af 50%, #2563eb 100%);
    padding: 10rem 0 5rem;
    text-align: center;
}

.page-header-rates .page-header-bg {
    background-image: url('https://images.unsplash.com/photo-1494412574643-ff11b0a5c1c3?w=1600&q=80');
    opacity: 0.15;
}

.page-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2rem;
    margin-top: 0.75rem;
    position: relative;
    z-index: 1;
}

/* ── Auth Bar ── */
.auth-bar {
    background: #f0f4ff;
    border-bottom: 1px solid #dbeafe;
    padding: 0.75rem 0;
}

.auth-bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.auth-bar-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e40af;
    font-size: 0.9rem;
}

.auth-bar-info svg {
    flex-shrink: 0;
}

.auth-bar-actions {
    display: flex;
    gap: 0.5rem;
}

.auth-bar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.4rem 0.8rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    border: 1px solid #dbeafe;
}

.tier-tag {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-auth {
    padding: 0.4rem 1rem;
    border-radius: 0.375rem;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-login {
    background: #1e40af;
    color: white;
}

.btn-login:hover {
    background: #1e3a8a;
    transform: translateY(-1px);
}

.btn-signup {
    background: white;
    color: #1e40af;
    border: 1px solid #1e40af;
}

.btn-signup:hover {
    background: #f0f4ff;
}

.btn-logout {
    background: transparent;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-logout:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* ── Search Card ── */
.rate-search-section {
    padding: 3rem 0;
    background: #f8fafc;
    min-height: 50vh;
}

.search-card {
    background: white;
    border-radius: 1.25rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 2.5rem;
    max-width: 900px;
    margin: 0 auto;
    border: 1px solid #f1f5f9;
}

.search-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.search-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.search-card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.15rem;
}

.search-card-header p {
    color: #64748b;
    font-size: 0.9rem;
}

/* ── Form ── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-group {
    position: relative;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}

.form-group label svg {
    color: #3b82f6;
}

.required {
    color: #ef4444;
}

.optional-tag {
    font-size: 0.7rem;
    font-weight: 400;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.625rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: #0f172a;
    background: #f8fafc;
    transition: all 0.2s ease;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group.error input,
.form-group.error select {
    border-color: #ef4444;
    background: #fef2f2;
}

.form-error {
    display: none;
    font-size: 0.78rem;
    color: #ef4444;
    margin-top: 0.35rem;
    padding-left: 0.25rem;
}

.form-group.error .form-error {
    display: block;
}

/* ── Autocomplete ── */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 0.625rem 0.625rem;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 0.65rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: #f0f4ff;
}

.autocomplete-item .port-name {
    font-weight: 500;
    color: #0f172a;
}

.autocomplete-item .port-country {
    font-size: 0.8rem;
    color: #64748b;
}

.autocomplete-item .port-code {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
}

/* ── Quantity Input ── */
.qty-input {
    display: flex;
    align-items: center;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.625rem;
    overflow: hidden;
    background: #f8fafc;
}

.qty-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    font-size: 1.25rem;
    color: #1e40af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-family: inherit;
    font-weight: 600;
}

.qty-btn:hover {
    background: #dbeafe;
}

.qty-input input {
    border: none !important;
    border-left: 1px solid #e2e8f0 !important;
    border-right: 1px solid #e2e8f0 !important;
    border-radius: 0 !important;
    text-align: center;
    width: 100%;
    padding: 0.75rem 0.5rem;
    background: white !important;
    font-weight: 600;
    -moz-appearance: textfield;
}

.qty-input input::-webkit-outer-spin-button,
.qty-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ── Weight Input ── */
.weight-input {
    position: relative;
}

.weight-input input {
    padding-right: 3rem !important;
}

.weight-unit {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
}

/* ── Search Button ── */
.btn-search {
    width: 100%;
    margin-top: 2rem;
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
    transition: all 0.25s ease;
}

.btn-search:hover {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35);
}

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

.btn-search.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ── Results Section ── */
.rate-results-section {
    padding: 3rem 0 5rem;
    background: #f8fafc;
}

.results-header {
    margin-bottom: 2rem;
}

.results-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
}

.results-header p {
    color: #64748b;
    margin-top: 0.35rem;
}

/* ── Results Loading ── */
.results-loading {
    text-align: center;
    padding: 4rem 2rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #1e40af;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.results-loading p {
    color: #64748b;
    font-size: 1rem;
}

/* ── Rate Card ── */
.results-grid {
    display: grid;
    gap: 1.25rem;
}

.rate-card {
    background: white;
    border-radius: 1rem;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: all 0.25s ease;
}

.rate-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.rate-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.route-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.port-info .port-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.port-info .port-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.port-info .port-country {
    font-size: 0.78rem;
    color: #64748b;
}

.route-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: #3b82f6;
    padding: 0 1rem;
    min-width: 100px;
}

.route-arrow .arrow-line {
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #93c5fd, #3b82f6);
    position: relative;
}

.route-arrow .arrow-line::after {
    content: '';
    position: absolute;
    right: -1px;
    top: -4px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 8px solid #3b82f6;
}

.route-arrow .transit-label {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    font-weight: 500;
}

.price-info {
    text-align: right;
}

.price-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 0.15rem;
}

.price-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1e40af;
}

.price-unit {
    font-size: 0.85rem;
    font-weight: 400;
    color: #64748b;
}

.rate-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.rate-details {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.rate-detail {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: #64748b;
}

.rate-detail strong {
    color: #334155;
}

.total-price {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
}

.btn-book {
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-book:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

/* ── Validity Badge ── */
.validity-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #ecfdf5;
    color: #059669;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ── Disclaimer ── */
.results-disclaimer {
    margin-top: 2rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 0.75rem;
    font-size: 0.82rem;
    color: #92400e;
}

.results-disclaimer svg {
    flex-shrink: 0;
    color: #f59e0b;
    margin-top: 0.1rem;
}

/* ── No Results ── */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
}

.no-results-icon {
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}

.no-results h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.5rem;
}

.no-results p {
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.no-results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn-outline {
    background: white;
    color: #1e40af;
    border: 2px solid #1e40af;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.btn-outline:hover {
    background: #f0f4ff;
    transform: translateY(-2px);
}

.no-results .btn-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: white;
    border-radius: 1.25rem;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 2.5rem;
    position: relative;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 1.3rem;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.modal-header p {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.modal-form-group {
    margin-bottom: 1rem;
}

.modal-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.4rem;
}

.modal-form-group input,
.modal-form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.625rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: #0f172a;
    background: #f8fafc;
    transition: all 0.2s ease;
    outline: none;
}

.modal-form-group input:focus,
.modal-form-group textarea:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-error {
    color: #dc2626;
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
    min-height: 1.2rem;
}

.btn-modal-submit {
    width: 100%;
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: white;
    padding: 0.85rem;
    border-radius: 0.625rem;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-modal-submit:hover {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

.modal-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: #64748b;
}

.link-btn {
    background: none;
    border: none;
    color: #1e40af;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    text-decoration: underline;
}

.link-btn:hover {
    color: #1e3a8a;
}

.modal-success {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 0.625rem;
    color: #059669;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.modal-success svg {
    flex-shrink: 0;
    color: #059669;
}

.booking-success {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 0.625rem;
    color: #059669;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.75rem;
}

.booking-success svg {
    flex-shrink: 0;
    color: #059669;
}

.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Booking Summary ── */
.booking-summary {
    background: #f0f4ff;
    border: 1px solid #dbeafe;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: #334155;
}

.booking-summary .booking-route {
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.booking-summary .booking-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .page-header-rates {
        padding: 8rem 0 3rem;
    }

    .page-subtitle {
        font-size: 1rem;
    }

    .auth-bar-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .auth-bar-info {
        justify-content: center;
    }

    .auth-bar-actions {
        justify-content: center;
    }

    .auth-bar-user {
        flex-direction: column;
        margin-left: 0;
    }

    .search-card {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    .search-card-header {
        flex-direction: column;
        text-align: center;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .rate-card-top {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem;
    }

    .route-info {
        flex-direction: column;
    }

    .route-arrow {
        transform: rotate(90deg);
        min-width: 60px;
        padding: 0.5rem;
    }

    .route-arrow .transit-label {
        transform: rotate(-90deg);
        margin-top: 0.25rem;
    }

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

    .rate-card-bottom {
        flex-direction: column;
        padding: 1rem;
        text-align: center;
    }

    .rate-details {
        justify-content: center;
    }

    .no-results-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-outline,
    .no-results .btn-cta {
        justify-content: center;
    }

    .modal-card {
        padding: 1.5rem;
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }

    .booking-summary {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .booking-summary .booking-route {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .search-card {
        padding: 1.25rem;
    }

    .search-card-header h2 {
        font-size: 1.25rem;
    }

    .results-header h2 {
        font-size: 1.35rem;
    }

    .price-value {
        font-size: 1.35rem;
    }
}