/* ============================================
   ROOT VARIABLES - Biological Dark Green Theme
   ============================================ */
:root {
    --bg-primary: #0a1a12;
    --bg-secondary: #0f241b;
    --bg-card: #162b20;
    --bg-card-hover: #1a3325;
    --text-primary: #e8f5e9;
    --text-secondary: #a5d6a7;
    --text-muted: #6d8f7a;
    --border-color: #2a4a3a;
    --accent-green: #43a047;
    --accent-green-light: #66bb6a;
    --accent-green-dark: #2e7d32;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Размеры для адаптивности */
    --header-font: 36px;
    --header-font-mobile: 24px;
    --container-padding: 40px 48px;
    --container-padding-mobile: 20px 16px;
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background-image: 
        radial-gradient(ellipse at 10% 20%, rgba(67, 160, 71, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(46, 125, 50, 0.05) 0%, transparent 50%);
    line-height: 1.6;
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: 820px;
    width: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: var(--container-padding);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-green-dark), var(--accent-green-light), var(--accent-green-dark));
    opacity: 0.6;
}

/* ============================================
   HEADER
   ============================================ */
header {
    text-align: center;
    margin-bottom: 32px;
}

.header-badge {
    margin-bottom: 12px;
}

.badge {
    display: inline-block;
    background: rgba(67, 160, 71, 0.15);
    color: var(--accent-green-light);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 4px 16px;
    border-radius: 20px;
    border: 1px solid rgba(67, 160, 71, 0.2);
}

header h1 {
    font-size: var(--header-font);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    word-break: break-word;
}

header .subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 300;
    margin-bottom: 16px;
}

.features-preview {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.features-preview span {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

/* ============================================
   UPLOAD AREA
   ============================================ */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.02);
    position: relative;
    touch-action: manipulation;
}

.upload-area:hover {
    border-color: var(--accent-green);
    background: rgba(67, 160, 71, 0.05);
}

.upload-area.dragover {
    border-color: var(--accent-green-light);
    background: rgba(67, 160, 71, 0.08);
    transform: scale(1.01);
}

.upload-area:active {
    transform: scale(0.98);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.upload-text {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
}

.upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ============================================
   CONTROLS
   ============================================ */
.controls {
    display: flex;
    gap: 14px;
    margin-top: 22px;
    justify-content: center;
    flex-wrap: wrap;
}

.controls button {
    padding: 12px 36px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    touch-action: manipulation;
    min-height: 48px;
    justify-content: center;
    flex: 1;
    min-width: 120px;
    max-width: 220px;
}

.btn-icon {
    font-size: 18px;
}

#analyzeBtn {
    background: var(--accent-green);
    color: white;
    box-shadow: 0 4px 16px rgba(67, 160, 71, 0.25);
}

#analyzeBtn:hover:not(:disabled) {
    background: var(--accent-green-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(67, 160, 71, 0.35);
}

#analyzeBtn:active:not(:disabled) {
    transform: scale(0.96);
}

#analyzeBtn:disabled {
    background: #2a4a3a;
    color: #6d8f7a;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

#clearBtn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

#clearBtn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

#clearBtn:active {
    transform: scale(0.96);
}

/* ============================================
   RESULT AREA
   ============================================ */
#resultContainer {
    margin-top: 30px;
    display: none;
}

#resultContainer.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

#imageWrapper {
    background: var(--bg-primary);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    position: relative;
}

#resultImage {
    width: 100%;
    height: auto;
    display: block;
}

#stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    padding: 16px 32px;
    border-radius: var(--radius-sm);
    text-align: center;
    min-width: 140px;
    flex: 1;
    max-width: 200px;
    border: 1px solid var(--border-color);
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-green-light);
    display: block;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================
   ACTION BUTTONS (Future Features)
   ============================================ */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.action-btn {
    padding: 8px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    touch-action: manipulation;
    white-space: nowrap;
}

.action-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-green);
    color: var(--text-secondary);
}

.action-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   LOADING
   ============================================ */
#loading {
    display: none;
    text-align: center;
    padding: 40px 20px;
    margin-top: 20px;
}

#loading.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-green-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#loading p {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
}

/* ============================================
   COMING SOON
   ============================================ */
.coming-soon {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border-color);
}

.coming-soon h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
    transition: var(--transition);
}

.feature-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-green-dark);
}

.feature-icon {
    font-size: 18px;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    width: 100%;
    max-width: 820px;
    padding: 0 8px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 0 8px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-muted);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-left a,
.footer-right a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-left a:hover,
.footer-right a:hover {
    color: var(--accent-green-light);
}

.footer-divider {
    opacity: 0.3;
}

.footer-right {
    display: flex;
    gap: 16px;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--accent-green-light);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ============================================
   ============================================
   ============================================
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ
   ============================================
   ============================================
   ============================================ */

/* Tablet & Small Laptops */
@media (max-width: 768px) {
    .container {
        padding: 30px 24px;
        border-radius: var(--radius-sm);
    }
    
    header h1 {
        font-size: 28px;
    }
    
    .features-preview {
        gap: 12px;
    }
    
    .features-preview span {
        font-size: 12px;
        padding: 3px 10px;
    }
    
    .upload-area {
        padding: 36px 16px;
    }
    
    .upload-icon {
        font-size: 40px;
    }
    
    .upload-text {
        font-size: 16px;
    }
    
    .controls button {
        padding: 10px 24px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .stat-card {
        padding: 14px 20px;
        min-width: 100px;
    }
    
    .stat-number {
        font-size: 28px;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }
    
    .container {
        padding: var(--container-padding-mobile);
        border-radius: var(--radius-sm);
        margin-bottom: 16px;
    }
    
    .container::before {
        height: 2px;
    }
    
    header {
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 22px;
        letter-spacing: -0.3px;
    }
    
    header .subtitle {
        font-size: 14px;
    }
    
    .header-badge {
        margin-bottom: 8px;
    }
    
    .badge {
        font-size: 10px;
        padding: 3px 12px;
    }
    
    .features-preview {
        gap: 8px;
    }
    
    .features-preview span {
        font-size: 10px;
        padding: 2px 8px;
        white-space: normal;
    }
    
    .upload-area {
        padding: 28px 12px;
        border-radius: var(--radius-sm);
    }
    
    .upload-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }
    
    .upload-text {
        font-size: 15px;
    }
    
    .upload-hint {
        font-size: 12px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 16px;
    }
    
    .controls button {
        padding: 12px 16px;
        font-size: 15px;
        min-height: 48px;
        max-width: 100%;
        flex: 1;
        width: 100%;
        justify-content: center;
    }
    
    .btn-icon {
        font-size: 16px;
    }
    
    #resultContainer {
        margin-top: 20px;
    }
    
    #stats {
        flex-direction: row;
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px 16px;
        min-width: 0;
        flex: 1;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .action-btn {
        padding: 10px 16px;
        font-size: 13px;
        width: 100%;
        text-align: center;
        white-space: normal;
    }
    
    #loading {
        padding: 24px 16px;
    }
    
    .spinner {
        width: 32px;
        height: 32px;
    }
    
    #loading p {
        font-size: 14px;
    }
    
    .coming-soon {
        margin-top: 24px;
        padding-top: 20px;
    }
    
    .coming-soon h3 {
        font-size: 14px;
    }
    
    .features-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .feature-item {
        padding: 8px 12px;
        font-size: 12px;
        gap: 8px;
    }
    
    .feature-icon {
        font-size: 16px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 6px;
        padding: 12px 0 4px;
        font-size: 12px;
    }
    
    .footer-left {
        justify-content: center;
    }
    
    .footer-right {
        justify-content: center;
        gap: 14px;
    }
}

/* Very small screens (<= 360px) */
@media (max-width: 360px) {
    .container {
        padding: 16px 12px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .upload-area {
        padding: 20px 10px;
    }
    
    .upload-text {
        font-size: 13px;
    }
    
    .controls button {
        font-size: 13px;
        padding: 10px 12px;
        min-height: 42px;
    }
    
    .stat-number {
        font-size: 20px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 16px 20px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .upload-area {
        padding: 16px 12px;
    }
    
    .upload-icon {
        font-size: 24px;
        margin-bottom: 4px;
    }
    
    .controls {
        flex-direction: row;
        margin-top: 12px;
    }
    
    .controls button {
        padding: 8px 16px;
        min-height: 36px;
        font-size: 13px;
    }
    
    .coming-soon {
        display: none;
    }
}

/* ============================================
   TOUCH-OPTIMIZED (для мобильных устройств)
   ============================================ */
@media (hover: none) {
    .controls button:hover:not(:disabled) {
        transform: none;
    }
    
    .upload-area:hover {
        border-color: var(--border-color);
        background: rgba(255, 255, 255, 0.02);
    }
    
    .action-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.03);
        border-color: var(--border-color);
        color: var(--text-muted);
    }
    
    .footer-left a:hover,
    .footer-right a:hover {
        color: var(--text-secondary);
    }
}

/* ============================================
   DARK MODE SUPPORT (System preference)
   ============================================ */
@media (prefers-color-scheme: light) {
    /* Не используем, так как у нас темная тема по умолчанию */
}