/*
 * Maker's Mark Identifier - Frontend Styles
 * Main stylesheet for the three-tab interface and identification workflow
 */

/* Container and Layout */
.mmi-app-container {
    max-width: 1200px;
    margin: 0 auto 4rem auto; /* Add bottom margin to prevent footer overlap */
    padding: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #000000; /* Black border for definition */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    min-height: calc(100vh - 8rem); /* Ensure proper height */
}

/* Header */
.mmi-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.mmi-header h2 {
    margin: 0;
    font-size: 2.5rem;
    color: #1e293b;
    font-weight: 700;
}

.mmi-header p {
    margin: 0.5rem 0 0 0;
    color: #64748b;
    font-size: 1.125rem;
}

/* Tab Navigation */
.mmi-tab-navigation {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    background: white;
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mmi-tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent; /* Default transparent - no !important */
    color: #64748b;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mmi-tab-btn:hover:not(.active) {
    background: #f1f5f9; /* Light gray on hover for non-active */
    color: #334155;
}

.mmi-tab-btn.active {
    background: #3b82f6 !important; /* Blue for active tab - keep !important here */
    color: white !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3) !important;
}

/* Tab Content */
.mmi-tab-content {
    position: relative;
    min-height: 600px;
}

.mmi-tab-panel {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.mmi-tab-panel.active {
    display: block;
}

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

/* Category Panel */
.mmi-category-panel {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mmi-category-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.mmi-category-icon {
    font-size: 3rem;
    line-height: 1;
}

.mmi-category-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: #1e293b;
    font-weight: 600;
}

.mmi-category-info p {
    margin: 0 0 1rem 0;
    color: #64748b;
    line-height: 1.6;
}

.mmi-category-tips {
    background: #f0f9ff;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    font-size: 0.875rem;
    color: #1e40af;
}

/* Upload Section */
.mmi-upload-section {
    margin-bottom: 2rem;
}

.mmi-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafbfc;
}

.mmi-upload-area:hover {
    border-color: #3b82f6;
    background: #f8faff;
}

.mmi-upload-area.drag-over {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: scale(1.02);
}

.mmi-upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.mmi-upload-icon:hover {
    color: #3b82f6;
    transform: scale(1.1);
}

.mmi-upload-icon:active {
    transform: scale(0.95);
}

.mmi-upload-text h4 {
    margin: 0 0 0.5rem 0;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 600;
}

.mmi-upload-text p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
}

/* File Preview */
.mmi-file-preview-container {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.mmi-file-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mmi-file-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.mmi-file-info h5 {
    margin: 0 0 0.25rem 0;
    color: #1e293b;
    font-weight: 600;
}

.mmi-file-info p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
}

.mmi-file-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

/* Identify Button */
.mmi-identify-container {
    text-align: center;
    margin: 2rem 0;
}

.mmi-identify-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.25);
}

.mmi-identify-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.35);
}

.mmi-identify-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Analysis Container */
.mmi-analysis-container {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.mmi-analysis-phase {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mmi-analysis-phase:last-child {
    border-bottom: none;
}

.mmi-phase-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.mmi-phase-icon.pending {
    background: #f1f5f9;
    color: #64748b;
}

.mmi-phase-icon.active {
    background: #dbeafe;
    color: #1d4ed8;
}

.mmi-phase-icon.completed {
    background: #dcfce7;
    color: #166534;
}

.mmi-phase-content h4 {
    margin: 0 0 0.25rem 0;
    color: #1e293b;
    font-weight: 600;
}

.mmi-phase-content p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
}

.mmi-phase-spinner {
    margin-left: auto;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Progress Bar Styles */
.mmi-phase-progress {
    margin-top: 0.5rem;
}

.mmi-progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.mmi-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 3px;
    transition: width 0.3s ease;
    position: relative;
}

.mmi-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Results Container */
.mmi-results-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 3rem; /* Add space before footer */
    position: relative;
    z-index: 1;
}

.mmi-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.mmi-results-header h3 {
    margin: 0;
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 600;
}

.mmi-confidence-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
}

.mmi-confidence-badge.high {
    background: #dcfce7;
    color: #166534;
}

.mmi-confidence-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.mmi-confidence-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

.mmi-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.mmi-result-section h4 {
    margin: 0 0 0.75rem 0;
    color: #374151;
    font-weight: 600;
    font-size: 1.125rem;
}

.mmi-result-value {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid #3b82f6;
    margin-bottom: 1rem;
    color: #1e293b;
    line-height: 1.6;
}

.mmi-additional-info {
    background: #f0f9ff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #bfdbfe;
    overflow: hidden; /* Prevent content overflow */
}

.mmi-additional-info h4 {
    margin: 0 0 1rem 0;
    color: #1e40af;
}

.mmi-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.mmi-info-item strong {
    display: block;
    color: #374151;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.mmi-info-item {
    color: #64748b;
    font-size: 0.875rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    line-height: 1.4;
}

/* Specific handling for URLs and long text */
.mmi-info-item a {
    word-break: break-all;
    color: #2563eb;
    text-decoration: underline;
}

.mmi-info-item strong + * {
    margin-top: 0.25rem;
    display: block;
}

/* Action Buttons */
.mmi-action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.mmi-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.mmi-btn-primary {
    background: #3b82f6;
    color: white;
}

.mmi-btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

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

.mmi-btn-secondary:hover {
    background: #e2e8f0;
}

/* Recent Identifications */
.mmi-recent-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #e2e8f0;
}

.mmi-recent-section h3 {
    margin: 0 0 1.5rem 0;
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.mmi-recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.mmi-recent-item {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.mmi-recent-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.mmi-recent-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.mmi-recent-category {
    font-size: 1.5rem;
}

.mmi-recent-info h5 {
    margin: 0;
    color: #1e293b;
    font-weight: 600;
}

.mmi-recent-info p {
    margin: 0.25rem 0 0 0;
    color: #64748b;
    font-size: 0.875rem;
}

.mmi-recent-confidence {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Loading States */
.mmi-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    color: #64748b;
}

.mmi-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Error States */
.mmi-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    color: #991b1b;
    text-align: center;
}

.mmi-error h4 {
    margin: 0 0 0.5rem 0;
    color: #dc2626;
}

/* Success States */
.mmi-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 1rem;
    color: #166534;
    text-align: center;
}

/* Mobile Upload Enhancements */
.mobile-upload .mmi-upload-icon {
    font-size: 4rem !important;
    padding: 1rem;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1) !important;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-upload .mmi-upload-icon:active {
    background: rgba(59, 130, 246, 0.2) !important;
    transform: scale(0.95);
}

.mobile-upload .mmi-upload-text h4 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

.mobile-upload .mmi-upload-text p {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Mobile camera input styling */
input[type="file"][accept*="image"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* This targets touch devices */
    .mmi-tab-btn {
        padding: 1.25rem 1.5rem;
        font-size: 1.05rem;
    }
    
    .mmi-upload-area {
        padding: 3rem 1.5rem !important;
        min-height: 250px;
    }
    
    button, .button, input[type="submit"] {
        min-height: 48px; /* iOS recommended touch target */
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* Responsive Design - Tablet */
@media (max-width: 1024px) {
    .mmi-app-container {
        padding: 1.5rem;
    }
    
    .mmi-header h2 {
        font-size: 2rem;
    }
    
    .mmi-results-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .mmi-app-container {
        padding: 1rem;
        margin: 0.5rem;
        border-radius: 8px;
        min-height: auto;
    }
    
    .mmi-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    
    .mmi-header h2 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .mmi-header p {
        font-size: 0.95rem;
        line-height: 1.4;
    }
    
    /* Stacked tab navigation on mobile */
    .mmi-tab-navigation {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .mmi-tab-btn {
        justify-content: flex-start;
        width: 100%;
        padding: 1rem;
    }
    
    /* Enhanced mobile upload area */
    .mmi-upload-area {
        padding: 2.5rem 1rem !important;
        text-align: center;
        min-height: 280px;
        border-width: 3px;
    }
    
    .mmi-upload-icon {
        font-size: 4rem !important;
        margin-bottom: 1.5rem;
        display: block;
    }
    
    .mmi-upload-text h4 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }
    
    .mmi-upload-text p {
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    /* Category header mobile optimization */
    .mmi-category-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .mmi-category-icon {
        font-size: 3rem;
        margin: 0 auto 0.5rem;
    }
    
    .mmi-category-info h3 {
        font-size: 1.5rem;
    }
    
    /* File preview mobile */
    .mmi-file-preview {
        max-width: 100%;
    }
    
    .mmi-file-preview img {
        max-height: 250px;
    }
    
    /* Results optimization for mobile */
    .mmi-results-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .mmi-result-card {
        padding: 1rem;
    }
    
    /* Action buttons stacked on mobile */
    .mmi-action-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .mmi-action-buttons button {
        width: 100%;
        justify-content: center;
    }
    
    /* Recent identifications mobile */
    .mmi-recent-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .mmi-info-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* Confidence meter mobile */
    .mmi-confidence-meter {
        font-size: 1.25rem;
    }
    
    /* Processing phases mobile */
    .mmi-phase-item {
        padding: 0.875rem 1rem;
    }
    
    /* Modal adjustments for mobile */
    .mmi-modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        margin: 5vh auto;
        padding: 1.5rem;
    }
}

/* Responsive Design - Small Mobile */
@media (max-width: 480px) {
    .mmi-app-container {
        padding: 0.75rem;
        margin: 0.25rem;
    }
    
    .mmi-header h2 {
        font-size: 1.5rem;
    }
    
    .mmi-header p {
        font-size: 0.875rem;
    }
    
    .mmi-tab-btn {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    .mmi-upload-area {
        padding: 2rem 0.75rem !important;
        min-height: 240px;
    }
    
    .mmi-upload-icon {
        font-size: 3.5rem !important;
    }
    
    .mmi-upload-text h4 {
        font-size: 1rem;
    }
    
    .mmi-upload-text p {
        font-size: 0.8125rem;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .mmi-app-container {
        min-height: auto;
    }
    
    .mmi-upload-area {
        min-height: 200px;
        padding: 1.5rem 1rem !important;
    }
    
    .mmi-upload-icon {
        font-size: 3rem !important;
        margin-bottom: 1rem;
    }
    
    .mmi-category-header {
        flex-direction: row;
        text-align: left;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific */
    input[type="file"] {
        cursor: pointer;
    }
    
    .mmi-upload-area {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
    }
    
    button, .button {
        -webkit-appearance: none;
        border-radius: 8px;
    }
}

/* Prevent zoom on input focus (mobile) */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
    }
}

/* Loading states mobile optimization */
@media (max-width: 768px) {
    .mmi-loading-spinner {
        width: 50px;
        height: 50px;
    }
    
    .mmi-processing-message {
        font-size: 0.95rem;
    }
}