/* Mobile Camera Capture Styles */

.camera-modal, .edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-modal.hidden, .edit-modal.hidden {
    display: none;
}

.camera-modal-content, .edit-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.edit-modal-content {
    max-width: 95vw;
    height: 90vh;
    max-height: 90vh;
}

.camera-header, .edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
    min-height: 48px;
}

.camera-header h3, .edit-header h3 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.camera-container {
    padding: 20px;
    text-align: center;
}

.camera-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 90vw;
    max-height: 60vh;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
}

.camera-container video {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 60vh;
    border-radius: 4px;
    background: #000;
    object-fit: contain;
}

.edit-container {
    padding: 5px;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.edit-container canvas {
    max-width: 100%;
    max-height: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: crosshair;
    object-fit: contain;
}

/* Crop overlay with draggable borders and corners */
.crop-overlay {
    position: absolute;
    pointer-events: none;
    border: 2px dashed #007bff;
    border-radius: 4px;
    background: rgba(0, 123, 255, 0.1);
}

.crop-overlay.hidden {
    display: none;
}

.crop-overlay.active {
    pointer-events: auto;
}

/* Crop handles for dragging */
.crop-handle {
    position: absolute;
    background: #007bff;
    border: 2px solid white;
    border-radius: 4px;
    width: 12px;
    height: 12px;
    cursor: pointer;
    z-index: 10;
}

/* Corner handles */
.crop-handle.corner-tl { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.corner-tr { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.corner-bl { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.corner-br { bottom: -6px; right: -6px; cursor: se-resize; }

/* Edge handles */
.crop-handle.edge-top { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle.edge-bottom { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle.edge-left { left: -6px; top: 50%; transform: translateY(-50%); cursor: w-resize; }
.crop-handle.edge-right { right: -6px; top: 50%; transform: translateY(-50%); cursor: e-resize; }

/* Crop action buttons */
.crop-actions {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 12px;
    border-radius: 20px;
    z-index: 11;
}

.crop-actions.hidden {
    display: none;
}

.crop-btn {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.crop-btn.cancel {
    background: #dc3545;
}

.crop-btn:hover {
    transform: scale(1.1);
}

/* Mobile responsive improvements */
@media (max-height: 600px) {
    .edit-header {
        padding: 6px 10px;
        min-height: 36px;
    }
    
    .edit-header h3 {
        font-size: 14px;
    }
    
    .edit-controls {
        padding: 4px 8px;
        min-height: 32px;
    }
    
    .edit-actions {
        padding: 4px 10px;
        min-height: 32px;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

.camera-controls, .edit-controls, .edit-actions {
    padding: 8px 15px;
    text-align: center;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.edit-controls {
    background: #f8f9fa;
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    justify-content: center;
    align-items: center;
    padding: 6px 10px;
    border-top: 1px solid #eee;
    overflow-x: auto;
    min-height: 40px;
    flex-shrink: 0;
}

.edit-actions {
    padding: 8px 15px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-shrink: 0;
    min-height: 50px;
}

.btn-primary, .btn-secondary, .btn-tool, .btn-icon, .btn-icon-small {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    margin: 0 5px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-tool {
    background-color: #e9ecef;
    color: #495057;
    padding: 8px 16px;
    font-size: 12px;
}

.btn-tool:hover {
    background-color: #dee2e6;
}

.btn-icon {
    background-color: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    min-width: 44px;
}

.btn-icon:hover {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-icon:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

/* Active state for mode buttons */
.btn-icon.active {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

/* Responsive scaling for very small screens */
@media (max-width: 400px) {
    .edit-controls {
        gap: 1px;
        padding: 6px 8px;
    }
    
    .btn-icon {
        width: 38px;
        height: 38px;
        font-size: 14px;
        margin: 0 1px;
        min-width: 38px;
    }
    
    .edit-actions {
        padding: 6px 10px;
    }
}

/* Ensure controls always fit horizontally */
@media (max-width: 350px) {
    .edit-controls {
        gap: 0px;
        padding: 6px 5px;
    }
    
    .btn-icon {
        width: 34px;
        height: 34px;
        font-size: 12px;
        margin: 0;
        min-width: 34px;
    }
}

.btn-icon .icon {
    display: block;
    line-height: 1;
}

/* Fix rotate-right icon orientation */
#rotate-right .icon {
    transform: scaleY(-1);
}

.camera-capture-btn {
    background-color: #007bff;
    color: white;
    margin-left: 10px;
    border: none;
    border-radius: 6px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.camera-capture-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

.camera-capture-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.camera-help-btn {
    background-color: transparent;
    color: #007bff;
    border: 2px solid #007bff;
    margin-left: 10px;
    border-radius: 6px;
    padding: 10px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.camera-help-btn:hover {
    background-color: #007bff;
    color: white;
    transform: translateY(-1px);
}

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

/* Hide camera button on desktop */
@media (min-width: 769px) {
    .camera-capture-btn {
        display: none !important;
    }
}

/* Mobile camera button styling */
@media (max-width: 768px) {
    .camera-capture-btn {
        display: inline-flex;
        width: auto;
        margin: 10px 0 0 0;
        padding: 14px 24px;
        font-size: 16px;
        border-radius: 8px;
        justify-content: center;
        min-width: 200px;
    }
    
    /* Stack buttons vertically on mobile */
    .upload-section tr:last-child td {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .upload-section input[type="submit"] {
        order: 3;
        width: 100%;
        padding: 14px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    .camera-capture-btn {
        order: 1;
        width: 100%;
        margin: 0;
    }
    
    .camera-help-btn {
        order: 2;
        width: 100%;
        margin: 0;
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 8px;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .camera-modal-content, .edit-modal-content {
        width: 98vw;
        height: 90vh;
        max-width: none;
        max-height: none;
        margin: 0;
    }

    .camera-container {
        padding: 10px;
    }

    .camera-container video {
        width: 100%;
        max-height: 50vh;
    }

    .edit-container {
        padding: 5px;
        flex: 1;
    }

    .edit-controls {
        flex-direction: row;
        gap: 4px;
        justify-content: center;
        flex-wrap: nowrap;
        padding: 6px 8px;
    }

    .btn-tool {
        width: auto;
        margin: 0;
    }

    .btn-icon {
        width: 42px;
        height: 42px;
        font-size: 16px;
        margin: 2px;
    }

    .btn-icon-small {
        width: 34px;
        height: 34px;
        font-size: 12px;
        margin: 2px;
    }

    .camera-controls, .edit-actions {
        padding: 8px;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        margin: 3px 0;
        padding: 10px;
        font-size: 14px;
    }
}

/* Ensure modals are above everything else */
.camera-modal, .edit-modal {
    z-index: 9999;
}

/* File input styling consistency */
input[type="file"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    width: 100%;
    box-sizing: border-box;
}

/* Upload form improvements for mobile */
@media (max-width: 768px) {
    .upload-section {
        padding: 10px;
    }
    
    .upload-section table {
        width: 100%;
    }
    
    .upload-section td {
        display: block;
        width: 100%;
        padding: 5px 0;
    }
    
    .upload-section input[type="text"], 
    .upload-section input[type="file"] {
        width: 100%;
        margin-top: 5px;
    }
}

/* Permission Modal Styles */
.permission-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.permission-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 300px;
}

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

.permission-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.permission-body {
    padding: 20px;
}

.permission-body p {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
}

.permission-instructions {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.permission-instructions strong {
    color: #333;
    display: block;
    margin-bottom: 5px;
}

.permission-instructions br {
    margin-bottom: 3px;
}

.permission-actions {
    margin-top: 20px;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.permission-actions .btn-primary,
.permission-actions .btn-secondary {
    margin: 0 5px;
    min-width: 100px;
}

/* Mobile optimizations for permission modal */
@media (max-width: 768px) {
    .permission-modal-content {
        width: 95vw;
        max-width: none;
        margin: 10px;
    }
    
    .permission-body {
        padding: 15px;
    }
    
    .permission-instructions {
        padding: 12px;
        font-size: 13px;
    }
    
    .permission-actions .btn-primary,
    .permission-actions .btn-secondary {
        width: 100%;
        margin: 5px 0;
    }
}