/*
 * File: css/tools.css
 * Description: MASTER Core styles for all tools - OPTIMIZED & ACCESSIBLE
 * Updated: January 2026 - PRODUCTION FIXED VERSION
 * 
 * FIXES APPLIED (ORIGINAL):
 * ✅ FIX #1: Mobile upload area reduced from 250px to 180px (better mobile UX)
 * ✅ FIX #2: Optimized padding for mobile devices (saves screen space)
 * ✅ FIX #3: Better responsive breakpoints for tablets
 * ✅ FIX #4: Improved touch targets for mobile (44px minimum)
 * ✅ FIX #5: Enhanced file input button visibility on mobile
 * ✅ FIX #6: Fixed thumbnail grid gap on small screens
 * ✅ FIX #7: Optimized font sizes for mobile readability
 * 
 * NEW FIXES APPLIED (BATCH 2 AUDIT):
 * ✅ NEW FIX #8: Fixed z-index variable names to match style.css
 * ✅ NEW FIX #9: Removed permanent will-change from shimmer animation
 * ✅ NEW FIX #10: Added iOS smooth scrolling to modal
 * ✅ NEW FIX #11: Added small tablet breakpoint (600-768px)
 */

/* NOTE: Local variables removed. We now use style.css as the Source of Truth. */

/* ===== SHARED TOOL LAYOUT ===== */
.tool-hero {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 0 20px; 
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 20px;
    margin-top: 20px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}

@supports (backdrop-filter: blur(10px)) {
    .tool-hero {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.6);
    }
}

.tool-hero h1 {
    font-size: 2.8rem;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tool-subtitle {
    font-size: 1.3rem;
    color: var(--tool-text-gray);
    max-width: 700px;
    margin: 0 auto 30px;
    line-height: 1.6;
    font-weight: 400;
}

/* ===== HERO STATS ===== */
.tool-stats {
    display: flex;
    justify-content: center;
    gap: 50px;
    flex-wrap: wrap;
    margin-top: 40px;
    padding: 25px;
    background: rgba(147, 112, 219, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(147, 112, 219, 0.1);
}

.stat {
    text-align: center;
    padding: 0 20px;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.95rem;
    color: var(--tool-text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Override for Homepage Dark Hero Section */
.hero .stat-number {
    color: #ffffff !important;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.hero .stat-label {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* ===== INTERFACE CONTAINER - GLASSY ===== */
.tool-interface {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    padding: 40px;
    margin-bottom: 50px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    position: relative;
}

@supports (backdrop-filter: blur(20px)) {
    .tool-interface {
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

/* ===== HOW-TO SECTION ===== */
.how-to-section {
    padding: 60px 0;
    background-color: transparent;
}

.how-to-section h2 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 50px;
    color: var(--text-dark);
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.step {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.step:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--primary-light);
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 50%;
    font-weight: 700;
    margin-bottom: 25px;
    font-size: 1.5rem;
    box-shadow: 0 5px 15px rgba(147, 112, 219, 0.3);
}

.step h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--text-dark);
    font-weight: 700;
}

.step p {
    color: var(--tool-text-gray);
    line-height: 1.6;
    font-size: 1.05rem;
}

/* ===== UPLOAD AREA ===== */
.upload-section {
    margin-bottom: 40px;
}

.upload-area {
    border: 3px dashed rgba(147, 112, 219, 0.3);
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(250, 251, 255, 0.9) 0%, rgba(255, 255, 255, 0.95) 100%);
    position: relative;
    overflow: hidden;
    min-height: 250px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ✅ NEW FIX #9: GPU-optimized shimmer without permanent will-change */
.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(147, 112, 219, 0.05), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    /* ✅ REMOVED: will-change - browser optimizes automatically */
}

/* ✅ NEW FIX #9: Add will-change only when hovering */
.upload-area:hover::before {
    will-change: transform;
    transform: translateX(100%);
}

.upload-area:hover, 
.upload-area:focus,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #f5f7ff 0%, #ffffff 100%);
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(147, 112, 219, 0.15);
}

.upload-icon {
    font-size: 80px;
    margin-bottom: 25px;
    display: block;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.upload-text {
    font-size: 1.5rem;
    margin-bottom: 15px;
    font-weight: 700;
    color: var(--text-dark);
}

.upload-subtext {
    color: var(--tool-text-gray);
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.upload-note {
    margin-top: 20px;
    color: var(--tool-text-gray);
    font-size: 0.95rem;
    padding: 12px 20px;
    background: rgba(147, 112, 219, 0.05);
    border-radius: 10px;
    display: inline-block;
    border: 1px solid rgba(147, 112, 219, 0.1);
}

/* ===== SHARED MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    /* ✅ NEW FIX #8: Use correct z-index variable from style.css */
    z-index: var(--z-modal, 2000);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    /* ✅ NEW FIX #10: Add iOS smooth scrolling */
    -webkit-overflow-scrolling: touch;
}

@supports (backdrop-filter: blur(5px)) {
    .modal {
        backdrop-filter: blur(5px); 
    }
}

.modal-content {
    background: #ffffff;
    padding: 0;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    animation: modalSlide 0.3s ease;
    border: 1px solid rgba(255,255,255,0.5);
    /* ✅ NEW FIX #8: Modal content sits above modal backdrop */
    z-index: calc(var(--z-modal, 2000) + 1);
    position: relative;
    margin: 20px auto;
}

@supports (backdrop-filter: blur(20px)) {
    .modal-content {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
    }
}

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

@media (prefers-reduced-motion: reduce) {
    .modal-content {
        animation: none;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--tool-text-gray);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 25px;
}

/* ===== BUTTONS & SPINNERS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(147, 112, 219, 0.3);
    position: relative;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    min-height: 44px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(147, 112, 219, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== THUMBNAILS ===== */
.thumbnails-container {
    margin-top: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.thumbnail {
    border: 2px solid rgba(224, 224, 224, 0.5);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: white;
}

.thumbnail.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(147, 112, 219, 0.2);
}

.thumbnail-canvas {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.thumbnail-canvas canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumbnail-number {
    text-align: center;
    padding: 5px;
    background: #f8f9fa;
    font-size: 0.85rem;
    color: var(--text-dark);
    border-top: 1px solid #f0f0f0;
    font-weight: 500;
}

.thumbnail.selected .thumbnail-number {
    background: var(--primary-color);
    color: white;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet-specific breakpoint (iPad, Android tablets) */
@media (max-width: 1024px) and (min-width: 769px) {
    .tool-interface {
        padding: 35px 25px;
    }
    
    .upload-area {
        padding: 50px 30px;
        min-height: 220px;
    }
    
    .tool-stats {
        gap: 30px;
    }
}

/* ✅ NEW FIX #11: Small tablet portrait mode (iPad Mini, small Android tablets) */
@media (max-width: 768px) and (min-width: 600px) {
    .upload-area {
        min-height: 200px;
        padding: 45px 25px;
    }
    
    .upload-icon {
        font-size: 70px;
        margin-bottom: 22px;
    }
    
    .upload-text {
        font-size: 1.35rem;
    }
    
    .upload-subtext {
        font-size: 1.05rem;
    }
    
    .thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .tool-interface {
        padding: 30px 20px;
    }
    
    .tool-stats {
        gap: 25px;
        padding: 22px 18px;
    }
}

/* Mobile optimization (phones) */
@media (max-width: 768px) {
    .tool-hero { 
        padding-top: 20px; 
        padding-bottom: 10px; 
    }
    
    .tool-hero h1 { 
        font-size: 2.2rem; 
    }
    
    .tool-subtitle { 
        font-size: 1.1rem; 
        margin-bottom: 20px; 
    }
    
    .tool-interface {
        padding: 25px 15px;
        margin-bottom: 30px;
    }
    
    .upload-area {
        min-height: 180px;
        padding: 40px 20px;
    }
    
    .upload-icon {
        font-size: 60px;
        margin-bottom: 20px;
    }
    
    .upload-text {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .upload-subtext {
        font-size: 0.95rem;
        margin-bottom: 20px;
    }
    
    .upload-note {
        font-size: 0.85rem;
        padding: 10px 15px;
        margin-top: 15px;
    }
    
    .steps { 
        grid-template-columns: 1fr; 
    }
    
    .stat-number { 
        font-size: 2rem; 
    }
    
    .tool-stats {
        gap: 20px;
        padding: 20px 15px;
    }
    
    .thumbnails {
        gap: 10px;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .thumbnail-canvas {
        height: 140px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px auto;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 15px;
        min-height: 44px;
    }
}

/* Small phone optimization (iPhone SE, small Android) */
@media (max-width: 375px) {
    .upload-area {
        min-height: 160px;
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 50px;
        margin-bottom: 15px;
    }
    
    .upload-text {
        font-size: 1.1rem;
    }
    
    .upload-subtext {
        font-size: 0.9rem;
    }
    
    .tool-hero h1 {
        font-size: 1.8rem;
    }
    
    .tool-subtitle {
        font-size: 1rem;
    }
    
    .thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .step {
        padding: 30px 20px;
    }
    
    .step-number {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        margin-bottom: 20px;
    }
}

/* Fix for passive event listener warnings */
.google-drive-btn, .dropbox-btn, .cloud-btn {
    touch-action: manipulation;
}

/* Fix for Google API scroll issues */
body {
    overscroll-behavior-y: contain;
}

/* Prevent touch callout on cloud buttons */
.cloud-btn {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}