/**
 * Shipping Modal Styles
 *
 * Comprehensive styles for the shipping calculator modal
 * Includes modal layout, form elements, tables, and responsive design
 *
 * @version 2.0.0
 * @author VenturaLine Development Team
 */

/* =====================================
   MODAL FOUNDATION & LAYOUT
   ===================================== */

.ship-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
}

.ship-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ship-modal__content {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 8px;
    width: min(90vw, 1000px);
    max-width: calc(100vw - 16px);
    min-width: min(400px, 90vw);
    height: fit-content;
    max-height: calc(100vh - 16px);
    min-height: 300px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15), 0 0 0 2px #3b82f6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}

.ship-modal__content::-webkit-resizer {
    background: linear-gradient(-45deg, transparent 0%, transparent 30%, #cbd5e1 30%, #cbd5e1 70%, transparent 70%, transparent 100%);
    border-radius: 0 0 12px 0;
}

.ship-modal__header {
    padding: 20px;
    border-bottom: 2px solid #3b82f6;
    position: relative;
    flex-shrink: 0;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 12px 12px 0 0;
    color: white;
    cursor: grab;
    user-select: none;
    position: relative;
}

.ship-modal__header:active {
    cursor: grabbing;
}

.ship-modal__title {
    margin: 0 0 8px 0;
    color: white;
    font-size: 24px;
    font-weight: 600;
}

.ship-modal__subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

/* =====================================
   MODAL HEADER & CLOSE BUTTON
   ===================================== */

.ship-modal__close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    font-size: 20px;
    font-weight: normal;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ship-modal__close-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    transform: translateY(-1px);
}

.ship-modal__close-button:active {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(0);
}

.ship-modal__close-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* Modal resize handle */
.ship-modal__resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(-45deg, transparent 0%, transparent 30%, #cbd5e1 30%, #cbd5e1 70%, transparent 70%, transparent 100%);
    cursor: nw-resize;
    border-radius: 0 0 12px 0;
    z-index: 10;
}

.ship-modal__resize-handle:hover {
    background: linear-gradient(-45deg, transparent 0%, transparent 30%, #94a3b8 30%, #94a3b8 70%, transparent 70%, transparent 100%);
}

/* =====================================
   MODAL BODY & CONTENT AREAS
   ===================================== */

.ship-modal__body {
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: white;
}

/* =====================================
   FORM ELEMENTS & VALIDATION
   ===================================== */

.ship-modal__form-section {
padding: 0 0 16px 0;
}

.ship-modal__form-section-title {
    margin: 0 0 20px 0;
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 8px;
    position: relative;
}

.ship-modal__form-section-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: #1d4ed8;
}

.ship-modal__form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.ship-modal__form-group {
    display: flex;
    flex-direction: column;
}

.ship-modal__form-group--full-width {
    grid-column: 1 / -1;
}

.ship-modal__form-label {
    margin-bottom: 6px;
    color: #4a5568;
    font-weight: 500;
    font-size: 14px;
}

.required {
    color: #dc2626;
    font-weight: 600;
    font-size: 1.1em;
    margin-left: 2px;
    text-shadow: 0 1px 2px rgba(220, 38, 38, 0.3);
    vertical-align: top;
}

.required::before {
    content: none;
}

.required:hover {
    color: #991b1b;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

.ship-modal__form-input {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: linear-gradient(to bottom, #ffffff, #fafafa);
}

.ship-modal__form-input:hover:not(:focus) {
    border-color: #cbd5e1;
    background: #ffffff;
}

.ship-modal__form-input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.ship-modal__form-select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: linear-gradient(to bottom, #ffffff, #fafafa);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

.ship-modal__form-select:hover:not(:focus) {
    border-color: #cbd5e1;
    background: #ffffff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
}

.ship-modal__form-select:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Error States */
.ship-modal__form-input--error,
.ship-modal__form-select--error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
    background-color: #fef2f2;
}

.ship-modal__form-input--error:focus,
.ship-modal__form-select--error:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

.ship-modal__form-group--error .ship-modal__form-label {
    color: #dc2626;
    font-weight: 600;
}

.ship-modal__form-field-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ship-modal__form-field-error::before {
    content: '*';
    font-size: 12px;
    font-weight: bold;
    margin-right: 2px;
}

.ship-modal__required {
    color: #dc2626;
    font-weight: 600;
    font-size: 1.1em;
    margin-left: 2px;
    text-shadow: 0 1px 2px rgba(220, 38, 38, 0.3);
    vertical-align: top;
}

.ship-modal__required:hover {
    color: #991b1b;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

/* Success States */
.ship-modal__form-input--success,
.ship-modal__form-select--success {
    border-color: #018641;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.ship-modal__form-group--success .ship-modal__form-label {
    color: #016848;
}

.ship-modal__form-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s ease;
    padding: 4px 0;
}

.ship-modal__form-checkbox-label:hover {
    color: #2563eb;
}

.ship-modal__form-checkbox-label input[type="checkbox"] {
    margin-right: 8px;
}

/* =====================================
   TABLE COMPONENTS & DATA DISPLAY
   ===================================== */

.ship-modal__form-info-message {
    background: #f7fafc;
    padding: 16px;
    border-radius: 8px;
    color: #4a5568;
    text-align: center;
}

.ship-modal__table-container {
    border-radius: 8px;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
}


.ship-modal__table-container::-webkit-scrollbar {
    height: 8px;
}

.ship-modal__table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
     border-radius: 8px;
}

.ship-modal__table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
      border-radius: 8px;
}

.ship-modal__table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.ship-modal__table {
    width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    min-width: max-content;
    overflow: hidden;
}



.ship-modal__table-cell {
    border-right: 2px solid #e2e8f0;
    padding: 4px;
    font-size: 14px;

    vertical-align: middle;
    transition: background-color 0.15s ease;
    text-align: center;
}

.ship-modal__table-cell--first {
    text-align: left;
    font-weight: 500;
    color: #374151;
}

.ship-modal__table-cell--last {
    text-align: right;
    font-weight: 600;
    color: #059669;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 15px;
}

.ship-modal__table--package {
    width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    min-width: max-content;
    overflow: hidden;
}

.ship-modal__table--package .ship-modal__table-header {
    color: #0b55c4;
    font-size: 13px;
    background-color: #f8f9fb;
    border-right:  2px solid #e2e8f0;
    border-bottom: 2px solid #0b55c4;
    font-weight: bold;
     padding: 4px;
    text-align: center;
    position: sticky;
    top: -1px;
}

.ship-modal__table--package .ship-modal__table-header:last-child {
    border-right: none;
}

.table--package .ship-modal__table-cell {
     padding: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    border-right:  2px solid #e2e8f0;

    text-align: center;
    color: #374151;
    cursor: pointer;
}

.ship-modal__table--package .ship-modal__table-cell:last-child {
    border-right: none;
}

.table--package tbody tr:nth-child(odd) {
    background: #e1ebfb;
}

.table--package tbody tr:nth-child(even) {
    background: #fff;
}

.ship-modal__table--package .ship-modal__table-cell:hover {
    overflow: visible;
}

.ship-modal__table--package tbody tr:not(:last-child) .ship-modal__table-cell {
    border-bottom: 2px solid #e2e8f0;
}

.table--package tbody tr:hover .ship-modal__table-cell {
    white-space: normal;
    background: #c9f0ff !important;
    text-rendering: optimizeSpeed;
}

.ship-modal__table--rates {
    width: 100%;
    table-layout: auto;
    border-radius: 4px;
    border-collapse: separate;
    border-spacing: 0;
    border:  2px solid #e2e8f0;
    min-width: max-content;
}

.ship-modal__table--rates .ship-modal__table-header {
    color: #0b55c4;
    font-size: 13px;

    background-color: #f8f9fb;
    border-right:  2px solid #e2e8f0;
    border-bottom: 2px solid #0b55c4;
    font-weight: bold;
    padding: 4px;
    position: sticky;
    top: -1px;
}

.ship-modal__table--rates .ship-modal__table-header:first-child {
    text-align: left;
}

.ship-modal__table--rates .ship-modal__table-header:last-child {
    text-align: right;
    border-right: none;
    white-space: nowrap;
}

.table--rates .ship-modal__table-cell {

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 4px;
    border-right:  2px solid #e2e8f0;
    font-size: 13px;
    cursor: pointer;
}

.ship-modal__table--rates .ship-modal__table-cell:last-child {
    border-right: none;
    white-space: nowrap;
    text-align: right;
}

.table--rates tbody tr:nth-child(odd) {
    background: #e1ebfb;
}

.table--rates tbody tr:nth-child(even) {
    background: #fff;
}

.ship-modal__table--rates .ship-modal__table-cell:hover {
    overflow: visible;
}

.ship-modal__table--rates tbody tr:not(:last-child) .ship-modal__table-cell {
    border-bottom: 2px solid #e2e8f0;
}

.table--rates tbody tr:hover .ship-modal__table-cell {
    white-space: normal;
    background: #c9f0ff !important;
    text-rendering: optimizeSpeed;
}

.ship-modal__rates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
}

@media (max-width: 768px) {
    .ship-modal__rates-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 640px) {
    .ship-modal__content {
        width: calc(100vw - 16px);
        min-width: 320px;
        max-height: calc(100vh - 16px);
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        resize: none;
    }

    .ship-modal__body {
        padding: 12px;
        gap: 12px;
    }

    .ship-modal__form-section {
        padding: 12px;
    }
}

.ship-modal__carrier-card {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ship-modal__carrier-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

.ship-modal__carrier-card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.ship-modal__carrier-card-logo {
    width: 60px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    color: white;
}

.ship-modal__carrier-card-logo--ups {
    background: #8B4513;
}

.ship-modal__carrier-card-logo--fedex {
    background: #4B0082;
}

.ship-modal__carrier-card-title {
    margin: 0;
    flex: 1;
    color: #2d3748;
    font-size: 16px;
    font-weight: 600;
}

.ship-modal__carrier-card-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3182ce;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ship-modal__carrier-card-body {
    padding: 16px;
    overflow-x: auto;
}

.ship-modal__carrier-card-body::-webkit-scrollbar {
    height: 6px;
}

.ship-modal__carrier-card-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.ship-modal__carrier-card-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ship-modal__carrier-card-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.ship-modal__carrier-card-placeholder {
    text-align: center;
    color: #718096;
    padding: 16px;
    font-style: italic;
}

.ship-modal__carrier-card-error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
}

.ship-modal__footer {
    padding: 20px;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 0 0 12px 12px;
    min-height: 84px;
    box-sizing: border-box;
}

.ship-modal__button {
    padding: 12px 16px;
    border: none;
       border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    position: relative;
    text-decoration: none;
    user-select: none;
    white-space: nowrap;

}

.ship-modal__button:hover, .ship-modal__button:active, .ship-modal__button:focus {
       border-radius: 4px;
}

.ship-modal__button--secondary {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #374151;
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 4px rgba(156, 163, 175, 0.15);
    border-radius: 4px;
}

.ship-modal__button--secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    border-color: #9ca3af;
    box-shadow: 0 4px 8px rgba(156, 163, 175, 0.2);
    color: #1f2937;
    border-radius: 4px;
}

.ship-modal__button--secondary:active:not(:disabled) {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
    box-shadow: inset 0 2px 4px rgba(156, 163, 175, 0.2);
    color: #1f2937;
    border-radius: 4px;
}

.ship-modal__button--primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: 1px solid #2563eb;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
           border-radius: 4px;
}

.ship-modal__button--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-color: #1d4ed8;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
           border-radius: 4px;
}

.ship-modal__button--primary:active:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: inset 0 2px 4px rgba(59, 130, 246, 0.3);
    color: white;
           border-radius: 4px;
}

.ship-modal__button:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    border-color: #e2e8f0 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.6;
}

.ship-modal__button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
