@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* { font-family: 'Inter', sans-serif; }

[x-cloak] { display: none !important; }

/* PWA / Web App tela cheia */
html {
    min-height: 100%;
    min-height: -webkit-fill-available;
    background-color: #0f172a;
}

body.pwa-app {
    min-height: 100%;
    min-height: -webkit-fill-available;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overscroll-behavior: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    body.pwa-app {
        padding-top: env(safe-area-inset-top);
    }

    .pwa-hide-standalone {
        display: none !important;
    }
}

body {
    background-color: #0f172a;
    background-image: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    min-height: 100vh;
    min-height: 100dvh;
    color: #e2e8f0;
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover::before { opacity: 1; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.2); }
    50% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.4); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.animate-fade-in { animation: fadeInUp 0.6s ease-out forwards; }
.animate-slide-in { animation: slideIn 0.5s ease-out forwards; }
.animate-pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }

.delay-100 { animation-delay: 0.1s; opacity: 0; }
.delay-200 { animation-delay: 0.2s; opacity: 0; }
.delay-300 { animation-delay: 0.3s; opacity: 0; }
.delay-400 { animation-delay: 0.4s; opacity: 0; }
.delay-500 { animation-delay: 0.5s; opacity: 0; }

.sidebar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
}

.sidebar-link {
    transition: all 0.2s;
    border-radius: 10px;
    position: relative;
}

.sidebar-link:hover, .sidebar-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.status-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.status-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.status-info { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }

.progress-ring {
    transform: rotate(-90deg);
}

.checklist-item {
    transition: all 0.2s;
    cursor: pointer;
}

.checklist-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.checklist-item.checked {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
}

.checklist-item.checked .check-icon {
    background: var(--success);
    border-color: var(--success);
}

.efficiency-ring {
    position: relative;
    width: 120px;
    height: 120px;
}

.efficiency-ring svg {
    transform: rotate(-90deg);
}

.efficiency-value {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
}

.gradient-text {
    background: linear-gradient(135deg, #a5b4fc, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-glow {
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    pointer-events: none;
}

.table-row {
    transition: background 0.2s;
}

.table-row:hover {
    background: rgba(99, 102, 241, 0.05);
}

.scan-area {
    border: 2px dashed rgba(99, 102, 241, 0.4);
    transition: all 0.3s;
}

.scan-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.form-input,
input, select, textarea {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid var(--glass-border) !important;
    color: #e2e8f0 !important;
    border-radius: 10px !important;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2) !important;
    outline: none !important;
}

select option {
    background-color: #0f172a;
    color: #e2e8f0;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 3px; }

/* Responsive */
@media (max-width: 1023px) {
    .glass-card:hover {
        transform: none;
        box-shadow: none;
    }
}

.pb-safe {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-nav .bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    font-size: 0.65rem;
    color: #94a3b8;
    transition: color 0.2s;
    min-width: 64px;
}

.mobile-bottom-nav .bottom-nav-link.active,
.mobile-bottom-nav .bottom-nav-link:hover {
    color: #a5b4fc;
}

.mobile-bottom-nav .scan-btn {
    color: #67e8f9;
    transform: translateY(-4px);
}

.mobile-bottom-nav .scan-btn.active {
    color: #22d3ee;
}

.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;
}

/* Checklist editor */
.checklist-editor-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.checklist-editor-row:hover {
    border-color: rgba(99, 102, 241, 0.25);
}

.checklist-editor-row.sortable-ghost {
    opacity: 0.35;
    border-style: dashed;
}

.checklist-editor-row.sortable-chosen {
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
}

.checklist-editor-row.is-deleted {
    opacity: 0.4;
}

.drag-handle {
    cursor: grab;
    color: #64748b;
    padding: 0.25rem;
    border-radius: 6px;
    flex-shrink: 0;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle:hover {
    color: #a5b4fc;
    background: rgba(255, 255, 255, 0.05);
}

.item-number {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.checklist-item-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px !important;
    padding: 0.625rem 0.875rem !important;
    font-size: 0.875rem !important;
}

.required-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.required-label {
    font-size: 0.7rem;
    color: #64748b;
    white-space: nowrap;
}

.required-toggle.is-on .required-label {
    color: #34d399;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch.toggle-sm {
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(100, 116, 139, 0.4);
    border-radius: 999px;
    transition: background 0.2s;
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-sm .toggle-slider::before {
    width: 14px;
    height: 14px;
}

.toggle-switch input:checked + .toggle-slider,
.required-toggle.is-on .toggle-slider {
    background: linear-gradient(90deg, #6366f1, #06b6d4);
}

.toggle-switch input:checked + .toggle-slider::before,
.required-toggle.is-on .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-sm input:checked + .toggle-slider::before,
.required-toggle.is-on.toggle-sm .toggle-slider::before,
.toggle-sm .required-toggle.is-on .toggle-slider::before {
    transform: translateX(16px);
}

.btn-remove-item {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s, background 0.2s;
}

.btn-remove-item:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
}

/* QR Scanner - iOS precisa de input visível (não display:none) */
.qr-touch-btn {
    position: relative;
    overflow: hidden;
    min-height: 3rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

.qr-file-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 3rem;
    opacity: 0.01;
    cursor: pointer;
    z-index: 20;
    font-size: 16px;
}

.qr-reader-live {
    min-height: 0;
    background: #000;
    position: relative;
}

.qr-reader-live.qr-reader-active {
    min-height: 55vh;
    max-height: 70vh;
}

#qr-reader video {
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px;
    object-fit: cover;
}

#qr-reader img {
    display: none;
}

#qr-reader > div {
    border: none !important;
}

#qr-reader #qr-shaded-region {
    border-width: 60px !important;
    border-color: rgba(0, 0, 0, 0.55) !important;
}

.qr-status {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    text-align: center;
}

.qr-status-info {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.qr-status-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.qr-status-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.qr-status-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

@media (max-width: 640px) {
    .status-badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .efficiency-ring {
        width: 100px;
        height: 100px;
    }

    .efficiency-value {
        font-size: 1.25rem;
    }
}

/* Touch-friendly checklist buttons */
@media (hover: none) {
    .checklist-item {
        min-height: 52px;
    }

    .btn-primary {
        min-height: 48px;
    }
}
