/* Main Layout - No Scroll */
.main {
    position: relative;
    height: calc(100dvh - 80px); /* Use dvh for mobile browser bars */
    overflow: hidden; /* Prevent scrolling */
    padding: 0; /* Remove all padding */
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0; /* Remove default padding */
    height: 100%;
    overflow: visible;
}

/* Hero Section - Full width redesign */
.hero {
    text-align: center;
    padding: clamp(3rem, 8vh, 5rem) var(--spacing-md);
    min-height: 95vh; /* Increased from 65vh to fill more screen */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    /* Full viewport width background */
    
    /* Seamless full width */
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-bottom: 0;
    padding-bottom: clamp(5rem, 12vh, 8rem); /* Increased bottom padding */
}

/* Remove the fade effect that was causing the gap */
.hero::after {
    display: none;
}

.hero-content {
    max-width: 600px;
    position: relative;
    z-index: 2;
}

/* Animated Icon */
.hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.25);
    animation: float 3s ease-in-out infinite;
    padding: 0.75rem;
}

.hero-icon svg {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.hero-logo-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.hero-title {
    font-size: var(--font-size-4xl);
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: var(--font-size-xl);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.6;
    font-weight: 500;
}

/* Hero Hint */
.hero-hint {
    margin-top: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Decorative Background Elements */
.hero-decoration {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
    filter: blur(60px);
    pointer-events: none;
    z-index: 1;
}

.hero-decoration-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    animation: pulse-slow 8s ease-in-out infinite;
}

.hero-decoration-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(110, 231, 183, 0.25) 0%, transparent 70%);
    bottom: -50px;
    left: -50px;
    animation: pulse-slow 8s ease-in-out infinite 4s;
}

@keyframes pulse-slow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.6;
    }
}

/* Recognition Section - Fit in 1 Screen, No Scroll */
.recognition-section {
    animation: fadeIn var(--transition-base);
    height: calc(100dvh - 120px); /* Use dvh for mobile */
    max-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm); /* Smaller gap */
    overflow: hidden; /* Prevent scrolling */
    position: relative; /* For absolute positioned button */
    padding: 0 var(--spacing-md); /* Add horizontal padding here instead */
}

/* Mobile ADD Button - Fixed at bottom center */
.btn-mobile-add {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom)); /* Safe area for notched phones */
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: white;
    border: none;
    border-radius: 50px; /* Pill shape */
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4), 0 4px 8px rgba(0, 0, 0, 0.2);
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    min-width: 160px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-mobile-add .add-icon {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.btn-mobile-add .add-text {
    letter-spacing: 0.5px;
    font-size: 1rem;
}

.btn-mobile-add:active {
    transform: translateX(-50%) scale(0.95);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-mobile-add.hidden {
    display: none !important;
}


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

.recognition-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr; /* Camera left, Detection+Reference right */
    grid-template-rows: auto 1fr; /* Word display top, main content bottom */
    gap: clamp(0.5rem, 1vw, 1rem); /* Responsive gap */
    flex: 1;
    min-height: 0;
    overflow: hidden; /* Prevent scrolling */
    grid-template-areas: 
        "word word"
        "camera right-panel";
}

/* Panel Styles */
.panel {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    overflow: hidden;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Grid area assignments */
.word-display-section {
    grid-area: word;
}

.camera-panel {
    grid-area: camera;
}

/* Right panel container - Detection + Reference horizontal */
.right-panel-container {
    grid-area: right-panel;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm); /* Smaller gap */
    min-height: 0;
}

/* Detection and Guide panels in horizontal layout */
.detection-panel,
.guide-panel {
    flex: 1;
    min-height: 0;
}

/* Guide panel needs visible overflow for hover previews */
.guide-panel {
    overflow: visible;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(0.4rem, 1.5vw, 1rem) clamp(0.5rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--glass-border);
}

.panel-title {
    font-size: var(--font-size-base); /* Smaller from xl */
    font-weight: 600;
    color: var(--color-text);
}

@media (max-width: 768px) {
    .panel-title {
        font-size: 0.8rem;
    }
}

.panel-body {
    padding: clamp(0.4rem, 1.5vw, 1rem);
    flex: 1;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
}

@media (max-width: 768px) {
    .status-badge {
        padding: 0.3rem 0.6rem;
        gap: 0.3rem;
    }
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

@media (max-width: 768px) {
    .status-text {
        font-size: 0.7rem;
    }
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Large Desktop (1200px+) - Default layout above */

/* Desktop/Laptop (1024px - 1199px) */
@media (max-width: 1199px) {
    .recognition-grid {
        grid-template-columns: 1.3fr 1fr;
        gap: var(--spacing-sm);
    }
}

/* Tablet Landscape (768px - 1023px) */
@media (max-width: 1023px) {
    .recognition-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas: 
            "word"
            "camera"
            "right-panel";
        gap: var(--spacing-xs);
    }
    
    .right-panel-container {
        flex-direction: row;
        gap: var(--spacing-xs);
    }
    
    .hero-title {
        font-size: var(--font-size-3xl);
    }
    
    .hero-icon {
        width: 85px;
        height: 85px;
    }
    
    .hero-icon svg {
        width: 60px;
        height: 60px;
    }
}

/* Mobile Landscape (480px - 767px, landscape) */
@media (max-width: 767px) and (orientation: landscape) {
    .main {
        height: calc(100dvh - 56px);
        padding: 0.25rem 0;
    }
    
    .recognition-section {
        height: calc(100dvh - 72px);
        gap: 0.25rem;
    }
    
    .recognition-grid {
        grid-template-columns: 1.5fr 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas: 
            "word word"
            "camera right-panel";
        gap: 0.4rem;
    }
    
    .right-panel-container {
        flex-direction: column;
    }
    
    .panel-title {
        font-size: var(--font-size-sm);
    }
    
    .word-display-panel {
        min-height: 48px;
        padding: 0.5rem 0.75rem;
    }
}

/* Mobile Portrait (< 768px) */
@media (max-width: 767px) and (orientation: portrait) {
    .main {
        height: calc(100dvh - 60px);
        padding: 0;
    }
    
    .main-container {
        padding: 0;
        overflow: visible;
    }
    
    /* Show mobile ADD button on portrait */
    .btn-mobile-add {
        display: flex;
    }

    .hero {
        padding: clamp(2rem, 6vh, 3rem) var(--spacing-sm);
        min-height: 75vh; /* Increased for mobile too */
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        width: 100vw;
        padding-bottom: clamp(4rem, 10vh, 6rem);
    }
    
    .hero::after {
        display: none;
    }
    
    .hero-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 1rem;
    }
    
    .hero-icon svg {
        width: 50px;
        height: 50px;
    }

    .hero-title {
        font-size: var(--font-size-2xl);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
        margin-bottom: var(--spacing-md);
    }
    
    .hero-hint {
        font-size: var(--font-size-xs);
    }
    
    .hero-decoration {
        display: none;
    }
    
    .recognition-section {
        height: calc(100dvh - 70px);
        gap: 0.5rem;
        padding: 0 0.5rem;
    }
    
    /* Mobile: Vertical stack layout */
    .recognition-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1.2fr 0.5fr;
        grid-template-areas: 
            "word"
            "camera"
            "right-panel";
        gap: 0.4rem;
    }
    
    .right-panel-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Hide guide panel on small mobile screens */
    .guide-panel {
        display: none;
    }

    .panel-body {
        padding: 0.5rem;
    }
    
    .panel-header {
        padding: 0.5rem 0.75rem;
    }
    
    .panel-title {
        font-size: var(--font-size-sm);
    }
}

/* Extra Small Mobile (< 375px) */
@media (max-width: 374px) {
    .recognition-grid {
        grid-template-rows: auto 1fr 0.9fr;
        gap: 0.4rem;
    }
    
    .main-container {
        padding: 0 0.4rem;
    }
    
    .panel-header {
        padding: 0.4rem 0.6rem;
    }
    
    .panel-body {
        padding: 0.4rem;
    }
}
