* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
}

@media (min-width: 768px) {
    body {
        padding: 20px;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    padding: 20px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

@media (min-width: 768px) {
    header {
        margin-bottom: 40px;
        padding: 30px;
    }
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
}

@media (min-width: 768px) {
    header h1 {
        font-size: 2.5em;
        margin-bottom: 10px;
    }
}

.subtitle {
    font-size: 1em;
    opacity: 0.9;
}

@media (min-width: 768px) {
    .subtitle {
        font-size: 1.2em;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 968px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        margin-bottom: 30px;
    }
}

.upload-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
    .upload-section {
        padding: 30px;
    }
}

.upload-box {
    border: 3px dashed #667eea;
    border-radius: 10px;
    padding: 25px 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .upload-box {
        padding: 40px;
    }
}

.upload-box:hover {
    border-color: #764ba2;
    background: #f8f9ff;
}

.upload-box.dragover {
    border-color: #764ba2;
    background: #f0f4ff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

@media (min-width: 768px) {
    .upload-icon {
        font-size: 4em;
        margin-bottom: 20px;
    }
}

.upload-box h3 {
    margin-bottom: 10px;
    color: #667eea;
    font-size: 1.1em;
}

@media (min-width: 768px) {
    .upload-box h3 {
        font-size: 1.3em;
    }
}

.upload-box p {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.9em;
}

@media (min-width: 768px) {
    .upload-box p {
        margin-bottom: 20px;
        font-size: 1em;
    }
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-height: 44px;
    min-width: 120px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    .btn-primary {
        padding: 12px 30px;
        min-height: auto;
        min-width: auto;
    }
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.file-info {
    margin-top: 15px;
    color: #666;
    font-size: 0.9em;
}

.preview-section {
    margin-top: 20px;
}

.preview-section h3 {
    margin-bottom: 15px;
    color: #667eea;
}

.image-preview {
    width: 100%;
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.results-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .results-section {
        padding: 30px;
    }
}

.results-section h2 {
    margin-bottom: 15px;
    color: #667eea;
    text-align: center;
    font-size: 1.5em;
}

@media (min-width: 768px) {
    .results-section h2 {
        margin-bottom: 20px;
        font-size: 2em;
    }
}

.result-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .result-card {
        padding: 25px;
    }
}

.result-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

@media (min-width: 480px) {
    .result-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0;
    }
}

.result-label {
    font-weight: bold;
    color: #666;
    font-size: 1em;
}

@media (min-width: 768px) {
    .result-label {
        font-size: 1.1em;
    }
}

.result-value {
    font-size: 1.2em;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    text-align: center;
}

@media (min-width: 768px) {
    .result-value {
        font-size: 1.5em;
        padding: 8px 20px;
    }
}

.result-value.defective {
    background: #ff6b6b;
    color: white;
}

.result-value.non-defective {
    background: #51cf66;
    color: white;
}

.confidence-bar-container {
    margin-bottom: 25px;
}

.confidence-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: bold;
    color: #666;
}

.confidence-bar {
    width: 100%;
    height: 28px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .confidence-bar {
        height: 30px;
    }
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9em;
}

.probabilities {
    margin-top: 20px;
}

.probabilities h4 {
    margin-bottom: 15px;
    color: #667eea;
}

.prob-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.annotated-image-section {
    margin-top: 20px;
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid #ff6b6b;
}

@media (min-width: 768px) {
    .annotated-image-section {
        margin-top: 30px;
        padding: 25px;
    }
}

.annotated-image-section h3 {
    color: #ff6b6b;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1.2em;
}

@media (min-width: 768px) {
    .annotated-image-section h3 {
        font-size: 1.4em;
    }
}

.annotation-note {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.annotated-image-container {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 3px solid #ff6b6b;
}

.annotated-image-container img {
    width: 100%;
    height: auto;
    display: block;
}

.coordinates-section {
    margin-top: 20px;
    background: linear-gradient(135deg, #f0f8ff 0%, #ffffff 100%);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid #667eea;
}

@media (min-width: 768px) {
    .coordinates-section {
        margin-top: 30px;
        padding: 25px;
    }
}

.coordinates-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.2em;
}

@media (min-width: 768px) {
    .coordinates-section h3 {
        margin-bottom: 20px;
        font-size: 1.4em;
    }
}

.coordinates-list {
    display: grid;
    gap: 15px;
}

.coordinate-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #ff6b6b;
}

@media (min-width: 768px) {
    .coordinate-item {
        padding: 15px;
    }
}

.coord-header {
    font-size: 1em;
    color: #ff6b6b;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

@media (min-width: 480px) {
    .coord-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0;
        font-size: 1.1em;
        margin-bottom: 12px;
    }
}

.coord-details {
    display: grid;
    gap: 8px;
}

.coord-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 0;
}

@media (min-width: 480px) {
    .coord-row {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0;
        padding: 5px 0;
    }
}

.coord-label {
    font-weight: 600;
    color: #666;
    font-size: 0.95em;
}

.coord-value {
    color: #333;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    word-break: break-all;
}

@media (min-width: 480px) {
    .coord-value {
        font-size: 0.9em;
        padding: 4px 10px;
        word-break: normal;
    }
}

.defect-count {
    margin: 15px 0;
    padding: 12px;
    background: #fff3cd;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

@media (min-width: 480px) {
    .defect-count {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
}

.defect-count-label {
    font-weight: 600;
    color: #856404;
}

.defect-count-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #ff6b6b;
    background: white;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .defect-count-value {
        font-size: 1.5em;
        padding: 5px 15px;
    }
}

.coord-confidence {
    font-size: 0.85em;
    color: #667eea;
    font-weight: normal;
}

@media (min-width: 480px) {
    .coord-confidence {
        font-size: 0.9em;
    }
}

.info-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (min-width: 968px) {
    .info-section {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        margin-top: 30px;
    }
}

.info-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
    .info-card {
        padding: 25px;
    }
}

.info-card h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.info-card ol, .info-card ul {
    margin-left: 20px;
    line-height: 1.8;
    color: #666;
}

.info-card code {
    background: #f4f4f4;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    display: block;
    margin: 10px 0;
    padding: 10px;
    overflow-x: auto;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 1em;
    text-align: center;
    padding: 0 20px;
}

@media (min-width: 768px) {
    .loading-overlay p {
        font-size: 1.2em;
    }
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Additional mobile optimizations */
@media (max-width: 480px) {
    .prob-item {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .confidence-label {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .probabilities h4 {
        font-size: 1.1em;
    }
    
    .preview-section h3 {
        font-size: 1.1em;
    }
}

/* Prevent text selection on buttons for better mobile UX */
.btn-primary {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Improve image responsiveness */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
    button, .upload-box {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
}

