/**
 * Order Modal Styles
 * Supports both Production (iPad optimized) and Backoffice modals
 */

/* Base Modal Styles */
/* Prevent layout shift when scrollbar is hidden */
body {
    transition: padding-right 0.15s ease;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000; /* Higher than sidebar (10001) */
    animation: fadeIn 0.2s ease-out;
    backdrop-filter: blur(2px);
    overscroll-behavior: contain;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

/* Production Modal - iPad Optimized */
.modal-production {
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
}

/* Backoffice Modal - Desktop Optimized */
.modal-backoffice {
    width: 90vw;
    max-width: 1400px;
    height: 85vh;
}

/* Modal Header - PDF Design Layout */
.modal-header {
    display: flex;
    align-items: flex-start;
    padding: 24px 32px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
    gap: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10;
}

/* Header Info Section - Left Column */
.header-info-section {
    display: flex;
    gap: 12px;
    flex: 0 0 auto;
    align-items: flex-start;
}

.header-labels {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    gap: 6px;
}

.header-labels > div {
    height: 24px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.header-values {
    display: flex;
    flex-direction: column;
    font-weight: 500;
    color: #111827;
    gap: 6px;
    font-size: 14px;
}

/* Order number specific styling */
.header-values > div {
    height: 24px;
    display: flex;
    align-items: center;
}

.header-values > div:first-child {
    font-size: 20px;
    font-weight: 700;
}

/* Header Customer Section - Middle Column */
.header-customer-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-customer-section .customer-company {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #111827;
    text-transform: uppercase;
    line-height: 1.2;
}

.customer-phone {
    font-size: 14px;
    color: #374151;
}

.customer-city {
    font-size: 14px;
    color: #374151;
    text-transform: lowercase;
}

/* Header Actions Section - Right Side */
.header-actions-section {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Simple Modal Header */
.modal-header-simple {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    gap: 24px;
}

.header-left {
    flex: 0 0 auto;
    min-width: 200px;
}

.modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.order-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
}

.order-site::after {
    content: '•';
    margin-left: 12px;
    color: #d1d5db;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.customer-info {
    max-width: 400px;
    width: 100%;
}

.customer-name {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 2px;
}

.customer-company {
    font-size: 15px;
    font-weight: 400;
    color: #6b7280;
    margin-bottom: 6px;
}

.customer-contact {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #6b7280;
}

.contact-item svg {
    width: 14px;
    height: 14px;
    color: #9ca3af;
    flex-shrink: 0;
}

.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header-info {
    flex: 1;
}

.modal-subtitle {
    display: flex;
    gap: 16px;
    margin-top: 4px;
    font-size: 14px;
    color: #6b7280;
}

/* Production Actions */
.production-actions {
    display: flex;
    gap: 8px;
}

/* Close Button */
.btn-close-modal {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s ease;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.btn-close-modal:hover {
    color: #111827;
    transform: scale(1.1);
}

.btn-close-modal:active {
    transform: scale(0.95);
}

/* Production Buttons */
.btn-production {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--btn-color, #667eea);
    color: white;
    min-height: 44px;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.01em;
}

.btn-production:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-production .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.btn-production .btn-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.btn-production .btn-text {
    display: inline-block;
    white-space: nowrap;
    font-weight: 500;
}

/* Backoffice Actions */
.backoffice-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Remove duplicate close button styles - already defined above */

/* Modal Body */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f3f4f6;
}

/* Customer Info Bar */
.customer-info-bar {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.customer-info-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.customer-company {
    font-size: 14px;
    color: #6b7280;
    font-style: italic;
}

.customer-name {
    font-size: 16px;
    color: #111827;
}

.customer-details {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: #6b7280;
    align-items: center;
}

.customer-phone,
.customer-city {
    display: flex;
    align-items: center;
    gap: 6px;
}

.customer-phone svg,
.customer-city svg {
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

/* Items Section */
.items-section {
    margin-bottom: 32px;
}

.items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.items-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.items-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-select-all {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-select-all:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* Removed color change when all items are selected
.btn-select-all.all-selected {
    background: #10b981;
    color: white;
    border-color: #10b981;
} */

.btn-select-all svg {
    width: 18px;
    height: 18px;
}

/* Production Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

.order-item {
    background: white;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-item-selectable {
    border-color: #e5e7eb;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.order-item-selectable:hover {
    border-color: #d1d5db;
    background: white;
}

.order-item-selectable.selected {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Ensure child elements don't interfere with clicking */
.order-item-selectable * {
    pointer-events: none;
}

.item-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-select {
    display: flex;
    align-items: flex-start;
    padding-top: 4px;
}

.item-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.item-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background: #e5e7eb;
    flex-shrink: 0;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-image-large {
    width: 100%;
    height: 250px;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-image-large img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-image-large .no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.item-details {
    flex: 1;
    min-width: 0;
}

.item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-name {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 500;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-meta {
    display: flex;
    gap: 12px;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 8px;
}

.item-meta-keys {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: white;
    padding: 0;
    border-radius: 6px;
}

.meta-item {
    font-size: 17px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.meta-item:last-child {
    border-bottom: none;
}

.meta-label {
    font-weight: 400;
    color: #374151;
    font-size: 17px;
    text-align: left;
}

.meta-value {
    color: #111827;
    font-weight: 600;
    font-size: 17px;
    text-align: right;
    margin-left: auto;
}

.item-footer {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 14px;
}

.item-quantity {
    font-weight: 500;
    color: #374151;
}

.item-price {
    font-weight: 600;
    color: #111827;
}

.item-dimensions {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    margin-bottom: 8px;
}

.item-note {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    color: #92400e;
    margin-top: 8px;
}

.item-status {
    position: absolute;
    top: 16px;
    right: 16px;
}

.item-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #f3f4f6;
    color: #6b7280;
}

.status-in-progress {
    background: #dbeafe;
    color: #1e40af;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-on-hold {
    background: #fef3c7;
    color: #92400e;
}

/* Backoffice Modal Content Grid */
.modal-content-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    height: 100%;
}

.modal-column-left,
.modal-column-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Section Cards */
.section-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

/* Order Details Grid */
.order-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.detail-value {
    font-size: 14px;
    color: #111827;
}

/* Customer Details */
.customer-primary h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.company-name {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

.customer-contact {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.contact-item a {
    color: #667eea;
    text-decoration: none;
}

.contact-item a:hover {
    text-decoration: underline;
}

/* Addresses */
.customer-addresses {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.address-block h5 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}

.address-block address {
    font-style: normal;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
}

/* Backoffice Items List */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.backoffice-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    gap: 12px;
    transition: all 0.2s ease;
}

.backoffice-item:hover {
    border-color: #d1d5db;
}

.item-content {
    display: flex;
    gap: 12px;
    flex: 1;
}

.backoffice-item .item-image {
    width: 60px;
    height: 60px;
}

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

.item-title {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
}

.item-sku {
    font-weight: 400;
    color: #6b7280;
}

.item-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.meta-item {
    font-size: 12px;
    color: #6b7280;
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.meta-item strong {
    color: #374151;
}

.item-actions {
    display: flex;
    gap: 4px;
}

.btn-item-action {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
}

.btn-item-action:hover {
    border-color: #d1d5db;
    color: #374151;
}

/* Item count styling */
.item-count {
    font-weight: 400;
    color: #6b7280;
    font-size: 16px;
}

/* Item quantity */
.item-quantity {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Activity Section */
.activity-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 24px;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.btn-refresh-activity {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
}

.btn-refresh-activity:hover {
    border-color: #d1d5db;
    transform: rotate(180deg);
}

/* Activity List - Production */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.activity-empty {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.activity-empty svg {
    margin: 0 auto 16px;
    opacity: 0.5;
}

.activity-empty p {
    margin: 0;
    font-size: 14px;
}

.no-activity {
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
    padding: 32px;
}

.activity-item {
    display: flex;
    gap: 20px;
    position: relative;
    padding-bottom: 24px;
}

.activity-item:last-child {
    padding-bottom: 0;
}

/* Timeline elements */
.activity-timeline {
    position: relative;
    width: 40px;
    flex-shrink: 0;
}

.activity-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e5e7eb;
    border: 2px solid #fff;
    position: absolute;
    left: 14px;
    top: 8px;
    z-index: 2;
}

.activity-dot.status_change {
    background: #3b82f6;
}

.activity-dot.production_step {
    background: #10b981;
}

.activity-dot.note_added {
    background: #f59e0b;
}

.activity-line {
    position: absolute;
    left: 19px;
    top: 20px;
    bottom: -24px;
    width: 2px;
    background: #e5e7eb;
}

/* Activity content */
.activity-content {
    flex: 1;
    display: flex;
    gap: 16px;
}

.activity-date {
    width: 100px;
    flex-shrink: 0;
    text-align: right;
    padding-top: 4px;
}

.activity-date-day {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.activity-date-time {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.activity-card {
    flex: 1;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    gap: 12px;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon.status_change {
    background: #dbeafe;
    color: #2563eb;
}

.activity-icon.note_added {
    background: #fef3c7;
    color: #d97706;
}

.activity-icon.item_updated {
    background: #e0e7ff;
    color: #6366f1;
}

.activity-icon.production_step {
    background: #d1fae5;
    color: #10b981;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    margin-bottom: 4px;
}

.activity-description {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}

.activity-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #9ca3af;
}

/* Activity Timeline - Backoffice */
.activity-timeline {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.activity-day {
    margin-bottom: 24px;
}

.activity-date {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.activity-events {
    position: relative;
    padding-left: 24px;
}

.activity-events::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 20px;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
}

.activity-event {
    position: relative;
    margin-bottom: 16px;
}

.activity-marker {
    position: absolute;
    left: -20px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e5e7eb;
}

.activity-status-change .activity-marker {
    border-color: #2563eb;
}

.activity-note-added .activity-marker {
    border-color: #d97706;
}

.activity-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.activity-time {
    font-size: 12px;
    color: #9ca3af;
}

.activity-details {
    background: #f9fafb;
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 2px 0;
}

.detail-key {
    color: #6b7280;
}

.detail-value {
    color: #111827;
    font-weight: 500;
}

.activity-footer {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
}

.activity-user {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Modal Footer */
.modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.footer-stats {
    display: flex;
    gap: 24px;
    font-size: 14px;
    color: #6b7280;
}

.footer-stats .selected-count {
    font-weight: 500;
}

.footer-stats .total-amount {
    font-weight: 600;
    color: #111827;
}

.footer-actions {
    display: flex;
    gap: 8px;
}

.footer-left,
.footer-right {
    display: flex;
    gap: 8px;
}

/* Common Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Note button styles */
.btn-note {
    background-color: #fbbf24;
    color: #78350f;
    font-weight: 600;
}

.btn-note:hover {
    background-color: #f59e0b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.btn-note.has-note {
    animation: subtlePulse 2s ease-in-out infinite;
}

@keyframes subtlePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(251, 191, 36, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
    }
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5b63d3;
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Note Dialog */
.note-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001;  /* Higher than modal overlay (99999) */
    animation: fadeIn 0.2s ease;
}

.note-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
    animation: slideUp 0.3s ease;
}

/* When note dialog is inside GlobalModal */
.global-modal.note-dialog-modal .note-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* Ensure proper z-index stacking with GlobalModal */
.modal-overlay.global-modal.note-dialog-modal {
    z-index: 100001 !important;  /* Higher than order modal */
}

.note-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.note-dialog-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.note-dialog-body {
    padding: 20px;
}

.note-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
}

.note-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.note-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
}

/* Loading States */
.activity-loading,
.no-activity,
.activity-error,
.no-items {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

/* Print Styles */
@media print {
    .modal-overlay {
        position: static;
        background: none;
    }
    
    .modal {
        box-shadow: none;
        height: auto;
        max-height: none;
    }
    
    .modal-header-actions,
    .btn-refresh-activity,
    .btn-item-action,
    .modal-footer,
    .item-select {
        display: none !important;
    }
    
    .modal-body {
        overflow: visible;
    }
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .modal-production {
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-radius: 0;
    }
    
    .modal-content-grid {
        grid-template-columns: 1fr;
    }
    
    .customer-addresses {
        grid-template-columns: 1fr;
    }
    
    /* Adjust header for iPad */
    .modal-header-simple {
        padding: 16px 20px;
    }
    
    .header-left {
        min-width: 180px;
    }
    
    .header-center {
        padding: 0 20px;
    }
    
    /* Ensure buttons are optimized for iPad */
    .btn-production {
        min-height: 48px;
        padding: 14px 24px;
        font-size: 16px;
    }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    .modal {
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-radius: 0;
    }
    
    /* Mobile header adjustments */
    .modal-header-simple {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }
    
    .header-left {
        min-width: 0;
        text-align: center;
    }
    
    .order-meta {
        justify-content: center;
    }
    
    .header-center {
        padding: 0;
        text-align: center;
    }
    
    .customer-contact {
        justify-content: center;
    }
    
    .header-right {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }
    
    .production-actions {
        flex: 1;
        gap: 8px;
    }
    
    .btn-production {
        flex: 1;
        justify-content: center;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .customer-name {
        font-size: 16px;
    }
    
    .customer-company {
        font-size: 14px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .order-details-grid {
        grid-template-columns: 1fr;
    }
}