/**
 * AtoShip Admin Styles
 * Styles for the label metabox and admin components
 */

/* ========================================
   Label Metabox - General
   ======================================== */

.atoship-label-info,
.atoship-rate-form {
    padding: 0;
}

.atoship-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.5;
    border-bottom: 1px solid #f0f0f0;
}

.atoship-label-row:last-child {
    border-bottom: none;
}

.atoship-label-row strong {
    flex-shrink: 0;
    margin-right: 8px;
    color: #1d2327;
}

.atoship-label-row span,
.atoship-label-row a {
    text-align: right;
    word-break: break-all;
    color: #50575e;
}

.atoship-label-row a {
    color: var(--wp-admin-theme-color, #2271b1);
    text-decoration: none;
}

.atoship-label-row a:hover {
    color: var(--wp-admin-theme-color-darker-10, #135e96);
    text-decoration: underline;
}

/* ========================================
   Field Groups (Ship From, Ship To, Package)
   ======================================== */

.atoship-field-group {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.atoship-field-group:last-of-type {
    border-bottom: 2px solid #e0e0e0;
}

.atoship-field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #1d2327;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.atoship-ship-from-select {
    width: 100%;
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    background: #fff;
    color: #1d2327;
}

.atoship-addresses-loading {
    text-align: center;
    padding: 2px 0;
}

.atoship-addresses-loading .spinner {
    margin: 0;
}

.atoship-ship-to-display {
    font-size: 12px;
    color: #50575e;
    padding: 4px 0;
}

/* ========================================
   Package Inputs
   ======================================== */

.atoship-package-inputs {
    /* Container */
}

.atoship-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 6px;
}

.atoship-input-row:last-child {
    margin-bottom: 0;
}

.atoship-input-field {
    flex: 1;
    min-width: 0;
}

.atoship-input-field label {
    display: block;
    font-size: 10px;
    color: #787c82;
    margin-bottom: 2px;
    text-transform: none;
    font-weight: normal;
}

.atoship-input-field input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    font-size: 12px;
    color: #1d2327;
    background: #fff;
    -moz-appearance: textfield;
}

.atoship-input-field input[type="number"]::-webkit-inner-spin-button,
.atoship-input-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.atoship-input-with-unit {
    display: flex;
    gap: 4px;
}

.atoship-input-with-unit input {
    flex: 1;
    min-width: 0;
}

.atoship-input-with-unit select,
.atoship-dim-unit,
.atoship-weight-unit {
    padding: 4px 4px;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    font-size: 11px;
    color: #1d2327;
    background: #fff;
    flex-shrink: 0;
    width: auto;
}

.atoship-dims-row {
    align-items: flex-end;
}

.atoship-dim-field {
    flex: 1;
    min-width: 0;
}

.atoship-dim-x {
    font-size: 12px;
    color: #a7aaad;
    padding-bottom: 4px;
    flex-shrink: 0;
}

/* ========================================
   Carrier Banner
   ======================================== */

.atoship-carrier-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.atoship-carrier-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.atoship-carrier-logo,
.atoship-carrier-logo img {
    display: block;
    border-radius: 4px;
    background: none;
}

/* Inline icon (atoship favicon next to labels) */
.atoship-inline-icon {
    display: inline-block;
    vertical-align: middle;
    margin-right: 3px;
    position: relative;
    top: -1px;
}

.atoship-carrier-name {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    white-space: nowrap;
}

.atoship-carrier-service {
    font-size: 12px;
    color: #787c82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   Progress Stepper
   ======================================== */

.atoship-stepper {
    position: relative;
    margin: 10px 0 14px;
}

.atoship-stepper-track {
    position: absolute;
    top: 8px;
    left: 12.5%;
    right: 12.5%;
    height: 2px;
    background: #dcdcde;
    z-index: 0;
}

.atoship-stepper-fill {
    height: 100%;
    background: #2bb77a;
}

.atoship-stepper-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: relative;
    z-index: 1;
}

.atoship-stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.atoship-stepper-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #dcdcde;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
}

.atoship-stepper-step.completed .atoship-stepper-dot {
    border-color: #2bb77a;
    color: #2bb77a;
}

.atoship-stepper-step.current .atoship-stepper-dot {
    width: 22px;
    height: 22px;
    margin-top: -2px;
    border-color: #2bb77a;
    background: #2bb77a;
    color: #fff;
}

.atoship-stepper-label {
    font-size: 10px;
    margin-top: 4px;
    color: #a7aaad;
    white-space: nowrap;
}

.atoship-stepper-step.completed .atoship-stepper-label {
    color: #787c82;
}

.atoship-stepper-step.current .atoship-stepper-label {
    color: #2bb77a;
    font-weight: 600;
}

/* ========================================
   Status Badge (fallback for exception/voided)
   ======================================== */

.atoship-label-status {
    margin-bottom: 12px;
    text-align: left;
}

.atoship-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.atoship-status-purchased .atoship-status-badge {
    background: #dff0d8;
    color: #3c763d;
}

.atoship-status-draft .atoship-status-badge {
    background: #fcf8e3;
    color: #8a6d3b;
}

.atoship-status-voided .atoship-status-badge {
    background: #f2dede;
    color: #a94442;
}

.atoship-status-shipped .atoship-status-badge {
    background: #e8f0fe;
    color: #1a56db;
}

.atoship-status-in_transit .atoship-status-badge {
    background: #d9edf7;
    color: #31708f;
}

.atoship-status-delivered .atoship-status-badge {
    background: #dff0d8;
    color: #3c763d;
}

.atoship-status-exception .atoship-status-badge {
    background: #fef3cd;
    color: #856404;
}

/* ========================================
   Tracking Timeline
   ======================================== */

.atoship-tracking-timeline {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.atoship-timeline-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    margin-bottom: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    color: #1d2327;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.5;
}

.atoship-timeline-toggle:hover {
    color: var(--wp-admin-theme-color, #2271b1);
}

.atoship-timeline-toggle strong {
    margin-right: 4px;
}

.atoship-toggle-count {
    font-size: 11px;
    color: #787c82;
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
}

.atoship-toggle-icon {
    margin-left: auto;
    font-size: 16px;
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.atoship-timeline-toggle[aria-expanded="true"] .atoship-toggle-icon {
    transform: rotate(180deg);
}

.atoship-timeline-events {
    position: relative;
    padding-left: 16px;
}

.atoship-timeline-event {
    position: relative;
    padding-bottom: 12px;
    padding-left: 10px;
    border-left: 2px solid #dcdcde;
    margin-left: 4px;
}

.atoship-timeline-event:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.atoship-event-dot {
    position: absolute;
    left: -6px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dcdcde;
    border: 2px solid #fff;
}

.atoship-event-latest .atoship-event-dot {
    background: var(--wp-admin-theme-color, #2271b1);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

.atoship-status-delivered .atoship-event-latest .atoship-event-dot,
.atoship-label-info .atoship-status-delivered ~ .atoship-tracking-timeline .atoship-event-latest .atoship-event-dot {
    background: #3c763d;
    box-shadow: 0 0 0 2px rgba(60, 118, 61, 0.2);
}

.atoship-event-content {
    min-height: 14px;
}

.atoship-event-desc {
    font-size: 12px;
    color: #1d2327;
    line-height: 1.4;
    word-wrap: break-word;
}

.atoship-event-latest .atoship-event-desc {
    font-weight: 600;
}

.atoship-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 2px;
    font-size: 11px;
    color: #787c82;
    line-height: 1.3;
}

.atoship-event-location::before {
    content: "\2022";
    margin-right: 4px;
}

.atoship-timeline-more {
    font-size: 11px;
    color: #787c82;
    padding: 4px 0 0 14px;
    font-style: italic;
}

/* ========================================
   Tracking Footer
   ======================================== */

.atoship-tracking-footer {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
}

.atoship-last-updated {
    font-size: 11px;
    color: #a7aaad;
}

/* ========================================
   Rates List
   ======================================== */

.atoship-rates-container {
    margin-top: 12px;
    margin-bottom: 0;
}

.atoship-rates-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #dcdcde;
    border-radius: 4px;
}

.atoship-rate-row {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    margin: 0;
    font-weight: normal;
    font-size: 13px;
}

.atoship-rate-row:last-child {
    border-bottom: none;
}

.atoship-rate-row-selectable {
    cursor: pointer;
    transition: background-color 0.15s;
}

.atoship-rate-row-selectable:hover {
    background-color: #f6f7f7;
}

.atoship-rate-row-selectable.atoship-rate-selected {
    background-color: #e8f0fe;
    border-color: #c3dafe;
}

.atoship-rate-row input[type="radio"] {
    margin: 0 8px 0 0;
    flex-shrink: 0;
}

.atoship-rate-logo {
    flex-shrink: 0;
    margin-right: 6px;
    border-radius: 3px;
    display: block;
}

.atoship-rate-info {
    flex: 1;
    min-width: 0;
}

.atoship-rate-service {
    display: block;
    font-size: 12px;
    color: #1d2327;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.atoship-rate-days {
    display: block;
    font-size: 11px;
    color: #787c82;
    line-height: 1.3;
}

.atoship-rate-price {
    flex-shrink: 0;
    margin-left: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}

/* Highlight selected rate */
.atoship-rate-selected .atoship-rate-service {
    color: var(--wp-admin-theme-color, #2271b1);
    font-weight: 600;
}

.atoship-rate-selected .atoship-rate-price {
    color: var(--wp-admin-theme-color, #2271b1);
}

/* Buy action below rates */
.atoship-rate-buy-action {
    margin-top: 8px;
    text-align: right;
}

.atoship-rate-buy-action .button {
    width: 100%;
    text-align: center;
    justify-content: center;
}

/* ========================================
   Confirm Panel
   ======================================== */

.atoship-confirm-panel {
    margin-top: 12px;
    padding: 12px;
    background: #f0f6fc;
    border: 1px solid #c3dafe;
    border-radius: 4px;
}

.atoship-confirm-rate {
    margin-bottom: 10px;
}

.atoship-confirm-carrier {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 4px;
}

.atoship-confirm-carrier img {
    border-radius: 3px;
}

.atoship-confirm-delivery {
    font-size: 11px;
    color: #787c82;
    margin-bottom: 6px;
}

.atoship-confirm-price {
    font-size: 18px;
    font-weight: 700;
    color: #1d2327;
}

.atoship-confirm-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.atoship-confirm-actions .button {
    flex: 1;
    text-align: center;
    justify-content: center;
}

/* ========================================
   Success Panel
   ======================================== */

.atoship-success-panel {
    margin-top: 12px;
    text-align: center;
}

.atoship-success-icon {
    margin-bottom: 8px;
}

.atoship-success-icon .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: #2bb77a;
}

.atoship-success-message {
    font-size: 14px;
    color: #1d2327;
    margin-bottom: 12px;
}

.atoship-success-details {
    text-align: left;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f6f7f7;
    border-radius: 4px;
}

.atoship-success-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    font-size: 12px;
    color: #50575e;
}

.atoship-success-row strong {
    color: #1d2327;
    word-break: break-all;
    text-align: right;
}

.atoship-success-actions {
    display: flex;
    gap: 6px;
}

.atoship-success-actions .button {
    flex: 1;
    text-align: center;
    justify-content: center;
}

/* ========================================
   Action Buttons
   ======================================== */

.atoship-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.atoship-actions .button {
    flex: 1;
    text-align: center;
    justify-content: center;
}

.atoship-label-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.atoship-label-actions .button {
    flex: 1;
    text-align: center;
}

/* ========================================
   Loading State
   ======================================== */

.atoship-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

.atoship-loading .spinner {
    float: none;
    margin: 0 8px 0 0;
}

.atoship-loading-text {
    font-size: 13px;
    color: #50575e;
}

/* ========================================
   Error / Notice
   ======================================== */

.atoship-error {
    margin: 8px 0;
}

.atoship-error p {
    margin: 0;
    padding: 8px 10px;
    background: #fcf0f1;
    border-left: 4px solid #d63638;
    color: #a94442;
    font-size: 13px;
}

.atoship-notice {
    padding: 8px 10px;
    font-size: 13px;
    margin: 0;
}

.atoship-notice-warning {
    background: #fcf8e3;
    border-left: 4px solid #dba617;
    color: #8a6d3b;
}

.atoship-notice a {
    color: inherit;
    text-decoration: underline;
}
