/**
 * TXS Webcam Capture Module - Styles
 * 
 * CSS for the webcam capture modal and UI components
 * Designed to work seamlessly with Dolibarr's existing styles
 * 
 * @author Technology Xchange Solutions
 * @version 1.0
 */

/* Modal Overlay */
.txs-webcam-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: txs-fadeIn 0.3s ease-out;
}

/* Modal Container - Styled to match Dolibarr's modal patterns */
.txs-webcam-modal {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 1600px; /* Content-based max width */
    min-width: 800px;  /* Ensure minimum usable width */
    width: auto;       /* Use only needed width */
    max-height: 95vh;  /* Use more screen height */
    overflow: hidden;
    animation: txs-slideIn 0.3s ease-out;
    font-family: inherit;
}

/* Modal Header - Styled to match Dolibarr's header patterns */
.txs-webcam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    border-radius: 4px 4px 0 0;
    gap: 20px;
}

.txs-webcam-header h3 {
    margin: 0;
    color: #26a7e1;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    flex: 1;
}

/* Camera Selector in Header */
.txs-webcam-camera-selector {
    flex: 0 0 auto;
    min-width: 200px;
}

.txs-webcam-camera-select {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    font-size: 13px;
    font-family: inherit;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.txs-webcam-camera-select:hover {
    border-color: #26a7e1;
}

.txs-webcam-camera-select:focus {
    outline: none;
    border-color: #26a7e1;
    box-shadow: 0 0 0 2px rgba(38, 167, 225, 0.1);
}

.txs-webcam-camera-select:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.txs-webcam-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #000;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
    font-weight: bold;
}

.txs-webcam-close-btn:hover {
    background: #e9ecef;
    color: #000;
}

/* Modal Content */
.txs-webcam-content {
    padding: 20px;
    background: #fff;
}

/* Main Content Layout */
.txs-webcam-main-content {
    display: flex;
    gap: 20px;
    min-height: 600px;  /* Larger minimum height */
    max-height: 85vh;   /* Use more screen height */
}

.txs-webcam-left-panel {
    flex: 1;
    min-width: 0;
    min-height: 0; /* Allow flex item to shrink */
    overflow: hidden; /* Prevent content from making panel grow */
}

.txs-webcam-right-panel {
    width: 200px;
    flex-shrink: 0;
    border-left: 1px solid #ddd;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    min-height: 600px;  /* Match larger main content height */
    max-height: 85vh;   /* Match main content height */
    overflow: hidden;   /* Prevent the panel itself from scrolling */
}

/* Camera Container */
.txs-webcam-camera-container {
    position: relative;
    margin-bottom: 20px;
    text-align: center;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
    width: 100%;
    max-width: 1200px; /* Increased from 800px for bigger preview */
    margin-left: auto;
    margin-right: auto;
    
    /* Fallback for older browsers - 16:9 aspect ratio using padding */
    padding-bottom: 56.25%; /* 9/16 = 0.5625 = 56.25% */
    height: 0;
    
    /* Modern browsers - 16:9 aspect ratio */
    aspect-ratio: 16 / 9;
    
    /* Ensure viewfinder doesn't exceed available space */
    max-height: calc(100vh - 300px); /* Reserve space for header, controls, and margins */
}

/* Modern browsers that support aspect-ratio */
@supports (aspect-ratio: 16 / 9) {
    .txs-webcam-camera-container {
        padding-bottom: 0;
        height: auto;
    }
}

.txs-webcam-camera,
.txs-webcam-preview {
    /* For fallback method - position absolutely within the padded container */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Fill the 16:9 container */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Hide any overflow to maintain aspect ratio */
}

/* Modern browsers that support aspect-ratio */
@supports (aspect-ratio: 16 / 9) {
    .txs-webcam-camera,
    .txs-webcam-preview {
        position: relative;
    }
}

.txs-webcam-camera video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Show full camera view without cropping */
    border-radius: 4px;
    background: #000; /* Black background for letterboxing if needed */
}

.txs-webcam-preview img {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    object-fit: contain; /* Show full image without cropping to match video display */
    background: #000; /* Black background for letterboxing if needed */
}

/* Controls - Styled to match Dolibarr's button patterns */
.txs-webcam-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Buttons styled to match Dolibarr's button classes */
.txs-webcam-btn {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    justify-content: center;
    text-decoration: none;
    font-family: inherit;
    background: #f0f0f0;
    color: #333;
}

.txs-webcam-btn:hover {
    background: #e6e6e6;
    border-color: #999;
    text-decoration: none;
}

.txs-webcam-btn:active {
    background: #ddd;
}

/* Primary button (Capture) - matches Dolibarr's primary action style */
.txs-webcam-btn.btn-primary {
    background: #26a7e1;
    color: white;
    border-color: #1e90d2;
}

.txs-webcam-btn.btn-primary:hover {
    background: #1e90d2;
    border-color: #1873b5;
    color: white;
}

/* Secondary button (Retake) */
.txs-webcam-btn.btn-secondary {
    background: #666;
    color: white;
    border-color: #666;
    }

.txs-webcam-btn.btn-secondary:hover {
    background: #5a6268;
    border-color: #545b62;
    color: white;
}

/* Success button (Accept) - matches Dolibarr's success style */
.txs-webcam-btn.btn-success {
    background: #28a745;
    color: #fff;
    border-color: #18642a;
}

.txs-webcam-btn.btn-success:hover {
    background: #1e7e34;
    border-color: #18642a;
    color: #fff;
}

/* Danger button (Cancel) - matches Dolibarr's danger style */
.txs-webcam-btn.btn-danger {
    background: #dc3545;
    color: White;
    border-color: #7c0f1a;
}

.txs-webcam-btn.btn-danger:hover {
    background: #c82333;
    border-color: #7c0f1a;
    color: #fff;
}

.txs-webcam-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f8f9fa !important;
    color: #6c757d !important;
    border-color: #dee2e6 !important;
}


#txs-webcam-title {
    color: #000;
    display: flex;
    align-items: end;
    gap: 10px;
}

#txs-webcam-title .fa-camera {
    color: #26a7e1;
    font-size: 2rem;
    margin: 0;
}
  
/* Guided Capture UI */
.txs-webcam-guided-info {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.5s ease;
}

.txs-webcam-guided-info.celebration {
    background: #cce7ff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    border: 1px solid #99d6ff;
}

.txs-webcam-guided-progress {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.txs-webcam-progress-bar {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.txs-webcam-progress-fill {
    height: 100%;
    background: #26a7e1;
    transition: width 0.3s ease;
    width: 0%;
}

.txs-webcam-guided-instruction {
    font-weight: 500;
    color: #333;
    text-align: center;
}

/* Thumbnails Panel */
.txs-webcam-thumbnails-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.txs-webcam-thumbnails-header h4 {
    display: none; /* Remove the "Uploaded Images" header */
}

.txs-webcam-thumb-nav {
    background: none;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 8px 12px;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    transition: all 0.2s ease;
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.txs-webcam-thumb-nav:hover {
    background: #f8f9fa;
    border-color: #999;
}

.txs-webcam-thumbnails {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    min-height: 0; /* Allow flex item to shrink below content size */
}

.txs-webcam-thumbnails::-webkit-scrollbar {
    width: 6px;
}

.txs-webcam-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.txs-webcam-thumbnails::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.txs-webcam-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.txs-webcam-thumbnail {
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.txs-webcam-thumbnail:hover {
    border-color: #26a7e1;
    box-shadow: 0 2px 4px rgba(38, 167, 225, 0.2);
}

.txs-webcam-thumbnail img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.txs-webcam-thumbnail-info {
    padding: 4px 6px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    line-height: 1.2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.txs-webcam-thumbnail-single {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 10px;
    color: #333;
    text-transform: capitalize;
    font-weight: normal;
    gap: 4px;
}

.txs-webcam-thumbnail-single .thumbnail-type {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txs-webcam-thumbnail-single .thumbnail-size {
    flex-shrink: 0;
    color: #666;
    font-weight: 500;
}

.txs-webcam-thumbnail-single .thumbnail-date {
    flex-shrink: 0;
    color: #666;
    font-size: 9px;
}

.txs-webcam-no-images {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.txs-webcam-thumbnails-footer {
    margin-top: 10px;
    text-align: center;
}

/* Image Preview Modal */
.txs-image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: txs-fadeIn 0.3s ease-out;
}

.txs-image-preview-container {
    background: #fff;
    border: 2px solid #26a7e1;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 95vw;
    max-height: 95vh;
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.txs-image-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.txs-image-preview-header h3 {
    margin: 0;
    color: #26a7e1;
    font-size: 18px;
    font-weight: 600;
}

.txs-preview-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 5px;
    font-size: 12px;
}

.txs-preview-details .detail-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #666;
    background: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

.txs-preview-details .detail-item i {
    font-size: 11px;
    width: 12px;
    text-align: center;
}

.txs-image-preview-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #000;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
}

.txs-image-preview-close:hover {
    color: #dc3545;
    transform: translateY(0) scale(1.3);
}

.txs-image-preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: #fff;
}

.txs-image-preview-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: #666;
    transition: all 0.2s ease;
    font-size: 3rem;
    z-index: 10;
    background-color: unset;
}

#txs-delete-image .fa-trash {
    color: inherit;
}

.txs-image-preview-nav:hover {
    color: #26a7e1;
    transform: translateY(-50%) scale(1.2);
}

.txs-image-preview-prev {
    left: 20px;
}

.txs-image-preview-next {
    right: 20px;
}

.txs-image-preview-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    height: 100%;
    overflow: hidden;  /* Hide overflow since images now scale to fit */
}

.txs-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.txs-image-container img {
    max-width: calc(100vw - 300px);  /* Full viewport minus nav buttons and padding */
    max-height: calc(100vh - 300px); /* Full viewport minus header and controls */
    width: auto;         /* Maintain aspect ratio */
    height: auto;        /* Maintain aspect ratio */
    object-fit: contain; /* Scale to fit while maintaining aspect ratio */
    cursor: zoom-in;
    transition: transform 0.1s ease-out;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.txs-image-preview-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

/* Update delete button to remove background and use text color */
.txs-image-preview-controls .btn-danger {
    background: #dc3545;
    color: #fff;
    border: 1px solid #dc3545;
}

.txs-image-preview-controls .btn-danger:hover {
    background: #dc3545;
    color: white;
}

/* Guided button styling - make it more prominent */
.txs-webcam-btn#txs-webcam-guided {
    background: #3ebf34;
    color: white;
    border-color: #3ebf34;
}

.txs-webcam-btn#txs-webcam-guided:hover {
    background: #34992c;
    border-color: #34992c;
    color: white;
}

/* Status messages - enhanced colors */
.txs-webcam-status {
    text-align: center;
    padding: 8px 12px;
    border-radius: 3px;
    font-size: 13px;
    min-height: 20px;
    border: 1px solid transparent;
    font-family: inherit;
}

.txs-webcam-status-info {
    background: #cce7ff;
    color: #0066cc;
    border-color: #99d6ff;
}

.txs-webcam-status-error {
    background: rgba(236, 10, 10, 0.35);
    color: #fff !important;
    border-color: #ec0a0a;
}

.txs-webcam-status-success {
    background: rgba(10, 236, 33, 0.35);
    color: #fff !important;
    border-color: #0aec1f;
}

.txs-webcam-status-warning {
    background: rgba(217, 236, 10, 0.35);
    color: #fff !important;
    border-color: #d9ec0a;
}

/* Preview Modal Status Messages */
.txs-preview-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    border: 1px solid transparent;
    font-family: inherit;
    animation: txs-statusAppear 0.4s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    white-space: nowrap;
}

@keyframes txs-statusAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.txs-preview-status-info {
    background: #cce7ff;
    color: #0066cc;
    border-color: #99d6ff;
}

.txs-preview-status-error {
    background: rgba(236, 10, 10, 0.35);
    color: #fff !important;
    border-color: #ec0a0a;
}

.txs-preview-status-success {
    background: rgba(10, 236, 33, 0.35);
    color: #fff !important;
    border-color: #0aec1f;
}

.txs-preview-status-warning {
    background: rgba(217, 236, 10, 0.35);
    color: #fff !important;
    border-color: #d9ec0a;
}

/* Loading Animation */
.txs-webcam-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #26a7e1;
    border-radius: 50%;
    animation: txs-spin 1s linear infinite;
}

/* Guided skip button styling */
.txs-webcam-skip-btn {
    background: #6c757d;
    color: white;
    border-color: #5a6268;
    margin-left: 10px;
}

.txs-webcam-skip-btn:hover {
    background: #5a6268;
    border-color: #545b62;
    color: white;
}

/* Image slide animations - smoother and more responsive */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.txs-image-slide-in-left {
    animation: slideInLeft 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.txs-image-slide-in-right {
    animation: slideInRight 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.txs-image-slide-out-left {
    animation: slideOutLeft 0.4s cubic-bezier(0.55, 0.06, 0.68, 0.19);
}

.txs-image-slide-out-right {
    animation: slideOutRight 0.4s cubic-bezier(0.55, 0.06, 0.68, 0.19);
}

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

@keyframes txs-slideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

@keyframes celebrationGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes celebrationBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) scale(1);
    }
    40% {
        transform: translateY(-10px) scale(1.05);
    }
    60% {
        transform: translateY(-5px) scale(1.02);
    }
}

@keyframes celebrationPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .txs-webcam-modal {
        width: 95%;
        min-width: auto; /* Remove min-width constraint on mobile */
        max-width: 95vw;
        margin: 10px;
    }
    
    .txs-webcam-content {
        padding: 15px;
    }
    
    .txs-webcam-main-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .txs-webcam-right-panel {
        width: auto;
        border-left: none;
        border-top: 1px solid #ddd;
        padding-left: 0;
        padding-top: 15px;
    }
    
    .txs-webcam-controls {
        flex-direction: column;
        align-items: center;
        /* Ensure controls are always visible */
        position: relative;
        z-index: 10;
        background: #f8f9fa;
        border-radius: 4px;
        padding: 10px;
        margin-top: 10px;
    }
    
    .txs-webcam-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .txs-webcam-header h3 {
        font-size: 16px;
    }
    
    .txs-webcam-camera-selector {
        min-width: 150px;
    }
    
    .txs-webcam-camera-select {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .txs-image-preview-container {
        width: 95vw;
        height: 85vh;
    }
    
    .txs-image-preview-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .txs-image-preview-prev {
        left: 10px;
    }
    
    .txs-image-preview-next {
        right: 10px;
    }

    .txs-image-container img {
        max-width: calc(100vw - 120px);  /* Smaller screens need less space */
        max-height: calc(100vh - 180px);
    }

    .txs-preview-details {
        gap: 8px;
    }

    .txs-preview-details .detail-item {
        font-size: 11px;
        padding: 3px 6px;
    }

    .txs-webcam-thumbnail-single {
        gap: 2px;
    }

    .txs-webcam-thumbnail-single .thumbnail-type {
        font-size: 9px;
    }

    .txs-webcam-thumbnail-single .thumbnail-size {
        font-size: 9px;
    }

    .txs-webcam-thumbnail-single .thumbnail-date {
        font-size: 8px;
    }
}

@media (max-width: 480px) {
    .txs-webcam-modal {
        width: 100%;
        min-width: auto; /* Remove min-width constraint on small mobile */
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        /* Ensure modal doesn't exceed screen bounds */
        max-width: 100vw;
        margin: 0;
    }
    
    .txs-webcam-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        position: relative;
    }
    
    .txs-webcam-camera-selector {
        min-width: 140px;
        order: 1;
    }
    
    .txs-webcam-camera-select {
        font-size: 11px;
        padding: 4px 6px;
    }
    
    .txs-webcam-close-btn {
        position: absolute;
        top: 0;
        right: 0;
    }
    
    .txs-webcam-camera-container {
        margin-bottom: 8px;
        /* Maintain 16:9 aspect ratio on mobile */
        aspect-ratio: 16 / 9;
        max-width: calc(100vw - 20px); /* Minimal margins on small screens */
        /* Ensure viewfinder fits on smaller screens */
        max-height: calc(100vh - 200px); /* Even less space on very small screens */
        /* Ensure controls are always visible */
    }
    
    .txs-webcam-thumbnails {
        max-height: 150px;
    }
    
    .txs-image-preview-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    
    .txs-image-preview-controls {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .txs-webcam-btn {
        min-width: 80px;
        font-size: 12px;
        padding: 6px 12px;
        /* Ensure buttons are always clickable */
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .txs-image-container img {
        max-width: calc(100vw - 80px);   /* Very small screens - minimal padding */
        max-height: calc(100vh - 160px);
    }

    .txs-preview-details {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }

    .txs-preview-details .detail-item {
        font-size: 10px;
        padding: 2px 5px;
    }

    .txs-image-preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .txs-webcam-thumbnail-single {
        flex-direction: column;
        gap: 1px;
        align-items: center;
    }

    .txs-webcam-thumbnail-single .thumbnail-type,
    .txs-webcam-thumbnail-single .thumbnail-size,
    .txs-webcam-thumbnail-single .thumbnail-date {
        font-size: 8px;
        text-align: center;
    }

    .txs-preview-status {
        font-size: 12px;
        padding: 10px 16px;
        max-width: 250px;
        border-radius: 4px;
    }
}

/* Dark Mode Support - Updated to match Dolibarr patterns */
@media (prefers-color-scheme: dark) {
    .txs-webcam-modal {
        background: #fff;
        color: #333;
        border-color: #ccc;
    }
    
    .txs-webcam-header {
        background: #f8f9fa;
        border-bottom-color: #ddd;
    }
    
    .txs-webcam-header h3 {
        color: #26a7e1;
    }
    
    .txs-webcam-close-btn {
        color: #000;
    }
    
    .txs-webcam-close-btn:hover {
        background: #e9ecef;
        color: #000;
    }
    
    .txs-webcam-content {
        background: #fff;
    }
    
    .txs-webcam-status-info {
        background: #cce7ff;
        color: #0066cc;
        border-color: #99d6ff;
    }
    
    .txs-webcam-status-error {
        background: rgba(236, 10, 10, 0.5);
        color: #830606 !important;
        border-color: #830606;
    }
    
    .txs-webcam-status-success {
        background: rgba(10, 236, 31, 0.5);
        color: #18642a !important;
        border-color: #18642a;
    }
    
    .txs-webcam-status-warning {
        background: rgba(217, 236, 10, 0.5);
        color: #838f06 !important;
        border-color: #838f06;
    }
    
    .txs-preview-status-info {
        background: #cce7ff;
        color: #0066cc;
        border-color: #99d6ff;
    }
    
    .txs-preview-status-error {
        background: rgba(236, 10, 10, 0.5);
        color: #fff;
        border-color: #830606;
    }
    
    .txs-preview-status-success {
        background: rgba(10, 236, 31, 0.5);
        color: #fff;
        border-color: #18642a;
    }
    
    .txs-preview-status-warning {
        background: rgba(217, 236, 10, 0.5);
        color: #fff;
        border-color: #838f06;
    }
    
    .txs-image-preview-container {
        background: #fff;
    }
    
    .txs-image-preview-header {
        background: #f8f9fa;
    }
}

/* Integration with Dolibarr styles */
.txs-webcam-btn.btn {
    font-family: inherit;
}

/* Camera permission message */
.txs-webcam-permission-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.txs-webcam-permission-message i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

/* Utility classes */
.txs-webcam-hidden {
    display: none !important;
}

.txs-webcam-visible {
    display: block !important;
}

.txs-webcam-text-center {
    text-align: center;
}

.txs-webcam-mb-2 {
    margin-bottom: 10px;
}

.txs-webcam-mb-3 {
    margin-bottom: 15px;
}

/* URL Upload Modal Styles */
.txs-url-upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: txs-fadeIn 0.3s ease-out;
}

.txs-url-upload-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
}

.txs-url-upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.txs-url-upload-header h3 {
    display:flex;
    align-items: end;
    margin: 0;
    color: #000;
    font-size: 18px;
    font-weight: 600;
}

.txs-url-upload-header h3 .fa-globe-americas {
    margin-right: 8px;
    color: #26a7e1;
    font-size: 2rem;
}

.txs-url-upload-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s ease;
    font-weight: bold;
}

.txs-url-upload-close-btn:hover {
    color: #dc3545;
    transform: scale(1.1);
}

.txs-url-upload-content {
    padding: 20px;
}

.txs-url-input-group {
    margin-bottom: 20px;
}

.txs-url-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.txs-url-input-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.txs-url-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.txs-url-input:focus {
    outline: none;
    border-color: #26a7e1;
    box-shadow: 0 0 0 2px rgba(38, 167, 225, 0.2);
}

.txs-url-paste-btn {
    padding: 10px 12px;
    background: #26a7e1;
    color: white;
    border: 1px solid #26a7e1;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.txs-url-paste-btn:hover {
    background: #1e8bbf;
    border-color: #1e8bbf;
}

.txs-url-paste-btn .fa-clipboard {
    font-size: 14px;
}

.txs-url-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    background: #f8f9fa;
}

.txs-url-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

.txs-url-preview-placeholder {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.txs-url-preview-placeholder .fa-image {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
    color: #ccc;
}

.txs-url-preview-placeholder p {
    margin: 0;
    font-style: italic;
}



.txs-url-upload-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.txs-url-upload-actions .btn {
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.txs-url-upload-actions .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.txs-url-upload-actions .btn-success {
    background: #3ebf34;
    color: white;
    border-color: #3ebf34;
}

.txs-url-upload-actions .btn-success:hover:not(:disabled) {
    background: #34992c;
    border-color: #34992c;
}

.txs-url-upload-actions .btn-secondary {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.txs-url-upload-actions .btn-secondary:hover {
    background: #444a4e;
    border-color: #444a4e;
}

.txs-url-upload-actions .btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.txs-url-upload-actions .btn-danger:hover {
    background: #8a1823;
    border-color: #8a1823;
}

.txs-url-upload-actions .btn-info {
    background: #17a2b8;
    color: white;
    border-color: #17a2b8;
}

.txs-url-upload-actions .btn-info:hover {
    background: #138496;
    border-color: #117a8b;
}

/* Enhanced Upload URL button styling */
.txs-webcam-btn#txs-webcam-upload-url {
    background: #b81698;
    color: white;
    border-color: #7e0f68;
}

.txs-webcam-btn#txs-webcam-upload-url:hover {
    background: #7e0f68;
    border-color: #7e0f68;
    color: white;
}

.txs-webcam-btn#txs-webcam-upload-url .fa-globe-americas {
    color: white;
}

/* Responsive design for URL upload modal */
@media (max-width: 768px) {
    .txs-url-upload-modal {
        width: 95%;
        margin: 10px;
    }
    
    .txs-url-upload-content {
        padding: 15px;
    }
    
    .txs-url-upload-actions {
        flex-direction: column;
    }
    
    .txs-url-upload-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .txs-url-input-container {
        flex-direction: column;
    }
    
    .txs-url-paste-btn {
        align-self: stretch;
    }
}

/* Quality Dropdown Styling */
.txs-webcam-quality-container {
    display: flex;
    align-items: center;
    margin-right: 5px;
}

.txs-webcam-quality-select {
    padding: 8px 12px;
    border: 1px solid #26a7e1;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
    height: 38px; /* Match button height */
    outline: none;
    transition: all 0.2s ease;
}

.txs-webcam-quality-select:hover {
    border-color: #1a8cbf;
    background: #f8f9fa;
}

.txs-webcam-quality-select:focus {
    border-color: #1a8cbf;
    box-shadow: 0 0 0 2px rgba(26, 140, 191, 0.2);
}

/* Update Options Modal Styles */
.txs-update-options-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: txs-fadeIn 0.3s ease-out;
}

.txs-update-options-container {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: txs-slideIn 0.3s ease-out;
    font-family: inherit;
}

.txs-update-options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
}

.txs-update-options-header h3 {
    margin: 0;
    color: #26a7e1;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.txs-update-options-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
    font-weight: bold;
}

.txs-update-options-close:hover {
    background: #e9ecef;
    color: #000;
}

.txs-update-options-content {
    padding: 20px;
    background: #fff;
}

.txs-update-options-content p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    text-align: center;
}

.txs-update-options-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.txs-update-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 15px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 80px;
    justify-content: center;
    position: relative;
    font-family: inherit;
}

.txs-update-option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.txs-update-option-btn i {
    font-size: 24px;
    margin-bottom: 8px;
}

.txs-update-option-btn span {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

.txs-update-option-btn small {
    font-size: 12px;
    opacity: 0.8;
    display: block;
}

.txs-update-option-btn.btn-primary {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.txs-update-option-btn.btn-primary:hover {
    background: #0056b3;
    border-color: #004085;
    color: white;
}

.txs-update-option-btn.btn-info {
    background: #17a2b8;
    color: white;
    border-color: #17a2b8;
}

.txs-update-option-btn.btn-info:hover {
    background: #117a8b;
    border-color: #0c5460;
    color: white;
}

.txs-update-option-btn.btn-success {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.txs-update-option-btn.btn-success:hover {
    background: #1e7e34;
    border-color: #155724;
    color: white;
}

/* Mobile responsiveness for update options modal */
@media (max-width: 768px) {
    .txs-update-options-container {
        width: 95%;
        margin: 10px;
    }
    
    .txs-update-options-header {
        padding: 15px;
    }
    
    .txs-update-options-header h3 {
        font-size: 16px;
    }
    
    .txs-update-options-content {
        padding: 15px;
    }
    
    .txs-update-option-btn {
        padding: 15px 10px;
        min-height: 70px;
    }
    
    .txs-update-option-btn i {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .txs-update-option-btn span {
        font-size: 14px;
    }
    
    .txs-update-option-btn small {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .txs-update-options-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .txs-update-options-header {
        padding: 12px;
        border-radius: 0;
    }
    
    .txs-update-options-content {
        padding: 12px;
    }
    
    .txs-update-options-buttons {
        gap: 10px;
    }
    
    .txs-update-option-btn {
        padding: 12px 8px;
        min-height: 60px;
    }
}