/* Dashboard Orders - Mobile-First Design */

/* Main container for user orders section */
.user-orders-section {
    background: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.user-dashboard-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

.user-dashboard-inner {
    padding: var(--space-6);
}

/* Header section */
.user-orders-header {
    padding: 1.5rem 1.5rem 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.user-orders-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-orders-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid #e5e7eb;
}

/* ============================================
   MOBILE CARD VIEW (Default)
   ============================================ */

.user-orders-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.user-orders-table-wrapper {
    display: none;
}

/* Order Card */
.order-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.order-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

/* Card Header */
.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.order-card-id {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #2563eb;
}

/* Route Section */
.order-card-route {
    padding: 1rem;
    background: #ffffff;
}

.route-point {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.route-point:last-of-type {
    margin-bottom: 0;
}

.route-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f0f9ff;
}

.route-icon.pickup {
    background: #dbeafe;
}

.route-icon.delivery {
    background: #d1fae5;
}

.route-text {
    flex: 1;
    min-width: 0;
}

.route-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.25rem;
}

.route-address {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
    word-break: break-word;
}

.route-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #9ca3af;
    margin: 0.25rem 0 0.25rem 0.9rem;
}

/* Info Grid */
.order-card-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.info-value {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.price-item {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    padding: 0.75rem;
    border-radius: 0.5rem;
}

.price-value {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.price-main-mobile {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e40af;
}

.price-vat-mobile {
    font-size: 0.75rem;
    font-weight: 500;
    color: #1e40af;
    opacity: 0.8;
}

/* Price Details Toggle */
.price-details-toggle {
    border-top: 1px solid #e5e7eb;
}

.price-details-summary {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.15s ease;
}

.price-details-summary::-webkit-details-marker {
    display: none;
}

.price-details-summary::after {
    content: '▼';
    font-size: 0.625rem;
    transition: transform 0.2s ease;
}

.price-details-toggle[open] .price-details-summary::after {
    transform: rotate(180deg);
}

.price-details-summary:active {
    background: #f9fafb;
}

.price-details-content {
    padding: 0 1rem 1rem 1rem;
    background: #f9fafb;
}

.price-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: #4b5563;
    border-bottom: 1px solid #e5e7eb;
}

.price-detail-row:last-child {
    border-bottom: none;
}

.price-detail-row.total {
    font-weight: 700;
    color: #111827;
    font-size: 1rem;
    padding-top: 0.75rem;
}

/* Action Button */
.order-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    background: #3b82f6;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.order-card-action:active {
    background: #2563eb;
}

/* Focus States for Accessibility */
.order-card-action:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================
   DESKTOP TABLE VIEW (769px+)
   ============================================ */

@media (min-width: 769px) {
    .user-orders-cards {
        display: none;
    }

    .user-orders-table-wrapper {
        display: block;
        width: 100%;
        overflow-x: auto;
    }

    .user-orders-table {
        width: 100%;
        border-collapse: collapse;
        background: #ffffff;
    }

    .user-orders-table th {
        background: #f9fafb;
        color: #1f2937;
        font-weight: 600;
        font-size: 0.875rem;
        text-align: left;
        padding: 1rem;
        border-bottom: 2px solid #e5e7eb;
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    /* Column header alignments to match cell alignments */
    .user-orders-table th:nth-child(4) { /* Matka */
        text-align: right;
        padding-right: 2rem;
    }
    .user-orders-table th:nth-child(5) { /* Hinta */
        text-align: right;
        padding-right: 2rem;
    }
    .user-orders-table th:nth-child(2) { /* Tila */
        text-align: center;
    }

    /* Price column header alignment */
    .user-orders-table th:nth-child(5) {
        text-align: right;
    }
    
    .user-orders-table th:nth-child(2) {
        text-align: left;
        padding-left: 60px;
    }

    .user-orders-table td {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        color: #111827;
        font-size: 0.875rem;
        line-height: 1.5;
        vertical-align: middle;
        background: #ffffff;
        font-weight: 500;
    }

    .user-orders-table tr {
        transition: background-color 0.15s ease-in-out;
    }

    .user-orders-table tr:hover {
        background: #f9fafb;
    }

    .user-orders-table tr:hover td {
        background: #f9fafb;
    }

    /* Column specific styling */
    .user-orders-id {
        font-weight: 600;
        color: #2563eb;
        min-width: 80px;
        white-space: nowrap;
    }

    .user-orders-route {
        min-width: 280px;
        font-weight: 500;
    }

    .user-orders-distance {
        min-width: 80px;
        color: #6b7280;
    }

    .user-orders-price {
        min-width: 140px;
        text-align: right;
    }

    .price-display {
        line-height: 1.2;
    }

    .price-main {
        font-size: 1.5rem;
        font-weight: 700;
        color: #111827;
    }

    .price-vat {
        font-size: 0.75rem;
        font-weight: 600;
        color: #6b7280;
        margin: 0.125rem 0;
    }

    .price-details {
        font-size: 0.6875rem;
        color: #9ca3af;
        font-weight: 400;
    }

    .user-orders-status {
        min-width: 200px;
        text-align: center;
        padding-left: 30px;
    }

    .user-orders-actions {
        min-width: 100px;
        text-align: center;
    }
}

/* ============================================
   SHARED COMPONENTS
   ============================================ */

/* Status badges */
.user-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.375rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
    min-width: 100px;
}

.user-status-badge.pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.user-status-badge.confirmed {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.user-status-badge.in-progress {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.user-status-badge.completed {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.user-status-badge.cancelled {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Action buttons (Desktop table) */
.user-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.875rem;
    background: #3b82f6;
    color: #ffffff;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.user-action-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

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

.user-action-btn:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

.trip-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    margin-left: 0.5rem;
}

.trip-type-badge.trip-type-meno {
    background: #3b82f6;
    color: #ffffff;
}

.trip-type-badge.trip-type-paluu {
    background: #f59e0b;
    color: #ffffff;
}

.user-orders-id .trip-type-badge {
    font-size: 0.75rem;
}

.order-card-id .trip-type-badge {
    font-size: 0.7rem;
}

.admin-table-row .trip-type-badge {
    font-size: 0.7rem;
}

.order-header .trip-type-badge,
.order-hero .trip-type-badge {
    margin-left: 0.75rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

/* Empty state */
.user-orders-empty {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: #9ca3af;
}

.empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #6b7280;
}

.empty-text {
    font-size: 0.9375rem;
    color: #9ca3af;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Mobile optimizations (up to 768px) */
@media (max-width: 768px) {
    .user-orders-header {
        padding: 1rem;
    }

    .user-orders-title {
        font-size: 1.125rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .user-orders-count {
        align-self: flex-start;
    }

    .user-orders-cards {
        padding: 0.75rem;
    }

    .order-card {
        border-radius: 0.625rem;
    }

    .order-card-header {
        padding: 0.875rem;
    }

    .order-card-route {
        padding: 0.875rem;
    }

    .order-card-info {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .route-address {
        font-size: 0.875rem;
    }

    .price-main-mobile {
        font-size: 1.125rem;
    }
}

/* Small mobile (up to 480px) */
@media (max-width: 480px) {
    .user-orders-section {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-left: -1rem;
        margin-right: -1rem;
    }

    .user-orders-header {
        padding: 0.875rem;
        border-radius: 0;
    }

    .user-orders-title {
        font-size: 1rem;
    }

    .user-orders-cards {
        padding: 0.625rem;
        gap: 0.875rem;
    }

    .order-card {
        border-radius: 0.5rem;
        border-left: none;
        border-right: none;
    }

    .order-card-header {
        padding: 0.75rem;
    }

    .order-card-id {
        font-size: 0.9375rem;
    }

    .user-status-badge {
        font-size: 0.6875rem;
        padding: 0.3125rem 0.625rem;
    }

    .order-card-route {
        padding: 0.75rem;
    }

    .route-point {
        gap: 0.625rem;
    }

    .route-icon {
        width: 28px;
        height: 28px;
    }

    .route-label {
        font-size: 0.6875rem;
    }

    .route-address {
        font-size: 0.8125rem;
    }

    .order-card-info {
        padding: 0.75rem;
        gap: 0.625rem;
    }

    .info-label {
        font-size: 0.6875rem;
    }

    .info-value {
        font-size: 0.9375rem;
    }

    .price-item {
        padding: 0.625rem;
    }

    .price-main-mobile {
        font-size: 1.0625rem;
    }

    .price-vat-mobile {
        font-size: 0.6875rem;
    }

    .price-details-summary {
        padding: 0.75rem;
        font-size: 0.8125rem;
    }

    .price-details-content {
        padding: 0 0.75rem 0.75rem 0.75rem;
    }

    .price-detail-row {
        font-size: 0.8125rem;
    }

    .order-card-action {
        padding: 0.875rem;
        font-size: 0.9375rem;
        min-height: 48px;
    }
}

/* Tablet (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {

    .user-orders-table th,
    .user-orders-table td {
        padding: 0.875rem;
        font-size: 0.8125rem;
    }

    .price-main {
        font-size: 1rem;
    }

    .user-orders-route {
        min-width: 240px;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .order-card {
        border: 2px solid #1f2937;
    }

    .order-card-header {
        border-bottom: 2px solid #1f2937;
    }

    .user-status-badge {
        border-width: 2px;
    }

    .order-card-action {
        border: 2px solid #1e40af;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .order-card,
    .order-card-action,
    .user-action-btn,
    .price-details-summary::after {
        transition: none;
    }

    .order-card:active {
        transform: none;
    }

    .user-action-btn:hover {
        transform: none;
    }
}

@supports (-webkit-overflow-scrolling: touch) {
    .user-orders-table-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}
