/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors - единая светлая тема */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    font-size: 14px;
}

/* Icons - используем эмодзи напрямую */
.icon-fire-extinguisher::before { content: "🔥"; }
.icon-qr-scanner::before { content: "📱"; }
.icon-camera::before { content: "📷"; }
.icon-stop::before { content: "⏹️"; }
.icon-keyboard::before { content: "⌨️"; }
.icon-search::before { content: "🔍"; }
.icon-arrow-right::before { content: "➡️"; }
.icon-check::before { content: "✅"; }
.icon-warning::before { content: "⚠️"; }
.icon-database::before { content: "💾"; }
.icon-scan::before { content: "✨"; }
.icon-test::before { content: "🧪"; }
.icon-arrow-left::before { content: "⬅️"; }

/* Убираем @font-face для иконок - используем эмодзи */

/* Layout */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: var(--space-lg) 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
    text-align: center;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.app-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
    width: 100%;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin-bottom: var(--space-xl);
    overflow: hidden;
}

.section-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between; /* Исправлено: было "between" */
    align-items: center;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Scanner Status */
.scanner-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--background);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

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

.status-indicator.scanning {
    background: var(--primary);
}

.status-indicator.error {
    background: var(--error);
}

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

/* Scanner Container */
.scanner-container {
    padding: var(--space-lg);
}

#scanner-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    aspect-ratio: 1;
}

#qr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#qr-canvas {
    display: none;
}

/* Scanner Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border: 2px solid transparent;
}

.scan-frame::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    animation: borderGlow 2s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary);
}

.corner.top-left {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: var(--radius-sm) 0 0 0;
}

.corner.top-right {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 var(--radius-sm) 0 0;
}

.corner.bottom-left {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 var(--radius-sm);
}

.corner.bottom-right {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.scan-line {
    position: absolute;
    top: 15%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: scanLine 2s linear infinite;
}

@keyframes scanLine {
    0% { top: 15%; }
    100% { top: 85%; }
}

.scan-text {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

/* Scanner Controls */
.scanner-controls {
    padding: 0 var(--space-lg) var(--space-lg);
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

/* Manual Input Section */
.manual-section {
    padding: var(--space-lg);
}

.manual-input-group {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    margin-bottom: var(--space-lg);
}

.input-wrapper {
    position: relative;
    flex: 1;
}

.text-input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) var(--space-2xl);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--text-primary); /* Добавлено для единообразия */
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.text-input::placeholder {
    color: var(--text-muted);
}

.input-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.quick-actions h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    font-weight: 500;
}

.quick-buttons {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.btn-quick {
    padding: var(--space-sm) var(--space-md);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-quick:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Statistics */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--surface);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.stat-icon.total {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    transform: translateY(-1px);
}

.btn-large {
    padding: var(--space-lg) var(--space-xl);
    font-size: 1rem;
}

/* Footer */
.app-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: var(--space-lg);
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: var(--space-md);
    }

    .app-title {
        font-size: 1.5rem;
    }

    .app-subtitle {
        font-size: 1rem;
    }

    .scanner-controls {
        flex-direction: column;
    }

    .manual-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-section {
        grid-template-columns: 1fr;
    }

    .footer-content {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }

    .section-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    :root {
        --space-md: 12px;
        --space-lg: 16px;
        --space-xl: 24px;
    }

    .app-title {
        font-size: 1.25rem;
    }

    .card {
        border-radius: var(--radius-lg);
    }

    .scan-frame {
        width: 80%;
        height: 80%;
    }
}

/* УБИРАЕМ медиа-запрос для темной темы - используем только светлую */
/* @media (prefers-color-scheme: dark) {
    ...
} */

/* Utility Classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.mb-0 { margin-bottom: 0; }
.mt-0 { margin-top: 0; }

/* Form Styles */
.form-content {
    padding: var(--space-lg);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
}

.form-section {
    background: var(--background);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin: var(--space-lg) 0;
    border: 1px solid var(--border-light);
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.form-section-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-lg);
}

.form-actions {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

/* Button Warning Variant */
.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-1px);
}

/* Responsive Form */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Textarea */
textarea.text-input {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Select Arrow */
select.text-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: var(--space-2xl);
}