/* =====================================================
   CHECKLIST - Estilos baseados na identidade visual CCTP
   ===================================================== */

/* Reset e Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Cores principais */
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-50: rgba(16, 185, 129, 0.1);

    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --amber-500: #f59e0b;
    --amber-50: #fffbeb;

    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-50: #fef2f2;

    --blue-100: #dbeafe;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;

    --yellow-500: #eab308;

    --white: #ffffff;

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

    /* Bordas */
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
}

html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    /* Desabilita pull-to-refresh */
    overscroll-behavior-y: contain;
}

body {
    background-color: var(--slate-100);
    color: var(--slate-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    /* Desabilita pull-to-refresh */
    overscroll-behavior-y: contain;
}

/* Container principal */
.container {
    max-width: 48rem;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: var(--white);
    padding: 1rem 1.5rem 0;
    border-bottom: 1px solid var(--slate-200);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background-color: rgba(255, 255, 255, 0.95);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding-bottom: 0.75rem;
}

.header-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--slate-200);
    flex-shrink: 0;
}

.header-text {
    flex: 1;
    min-width: 0;
}

header h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--slate-900);
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barra de status (online/offline) */
.status-bar {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--slate-500);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background-color: var(--red-500);
    transition: background-color 0.3s ease;
    animation: pulse-offline 2s infinite;
}

.status-indicator.online {
    background-color: var(--emerald-500);
    animation: pulse-online 2s infinite;
}

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

@keyframes pulse-online {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

.separator {
    color: var(--slate-300);
}

/* Barra de progresso */
.progress-bar-container {
    height: 4px;
    background: var(--slate-200);
    margin: 0 -1.5rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--emerald-500), var(--emerald-600));
    width: 0%;
    transition: width 0.3s ease;
}

/* Main content */
main {
    flex: 1;
    padding: 1rem;
}

/* Card de item do checklist */
.checklist-item {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--slate-200);
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
}

.checklist-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--slate-300);
    transition: background-color 0.3s ease;
}

.checklist-item.completed::before {
    background-color: var(--emerald-500);
}

.checklist-item.partial::before {
    background-color: var(--blue-600);
}

.checklist-item.pending::before {
    background-color: var(--amber-500);
}

/* Item de assinatura (destaque especial) */
.checklist-item.signature {
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    border: 2px solid var(--yellow-500);
    margin-top: 1.5rem;
}

.checklist-item.signature::before {
    background-color: var(--yellow-500);
    width: 5px;
}

.checklist-item.signature.completed {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: var(--emerald-500);
}

.checklist-item.signature.completed::before {
    background-color: var(--emerald-500);
}

.checklist-item.signature .checklist-item-title {
    font-size: 1.1rem;
}

.checklist-item.signature .signature-icon {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.checklist-item-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

/* Checkbox customizado */
.checkbox-wrapper {
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-wrapper input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 32px;
    height: 32px;
    border: 3px solid var(--slate-400);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--slate-100);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.checkbox-custom:hover {
    border-color: var(--emerald-500);
    background-color: var(--emerald-50);
}

.checkbox-custom:active {
    transform: scale(0.95);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom {
    background-color: var(--emerald-500);
    border-color: var(--emerald-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom:hover {
    background-color: var(--emerald-600);
    border-color: var(--emerald-600);
}

.checkbox-custom svg {
    width: 18px;
    height: 18px;
    stroke: var(--white);
    stroke-width: 3;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom svg {
    opacity: 1;
    transform: scale(1);
}

/* Conteúdo do item */
.checklist-item-content {
    flex: 1;
    min-width: 0;
}

.checklist-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--slate-900);
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.checklist-item.completed .checklist-item-title {
    color: var(--slate-500);
}

/* Badge de status do item */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    margin-left: 0.5rem;
    vertical-align: middle;
}

.status-badge.pending {
    background-color: var(--amber-50);
    color: #b45309;
}

.status-badge.partial {
    background-color: var(--blue-100);
    color: var(--blue-700);
}

.status-badge.done {
    background-color: var(--emerald-50);
    color: var(--emerald-600);
}

.checklist-item-obs {
    font-size: 0.875rem;
    color: var(--slate-600);
    line-height: 1.5;
}

/* Área de observação do usuário */
.observation-area {
    padding: 0.75rem 1.5rem 1rem;
    border-top: 1px solid var(--slate-100);
}

.observation-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.5rem;
}

.observation-label svg {
    color: var(--slate-400);
}

.observation-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--slate-800);
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    resize: vertical;
    min-height: 60px;
    transition: all 0.2s ease;
}

.observation-input::placeholder {
    color: var(--slate-400);
}

.observation-input:focus {
    outline: none;
    border-color: var(--emerald-500);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Área de foto */
.photo-area {
    padding: 0.75rem 1.5rem 1rem;
    border-top: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.photo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
}

.photo-badge.required {
    background-color: var(--red-50);
    color: var(--red-500);
}

.photo-badge.optional {
    background-color: var(--blue-100);
    color: var(--blue-700);
}

.btn-photo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--white);
    background-color: var(--emerald-500);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-photo:hover {
    background-color: var(--emerald-600);
}

.btn-photo:disabled {
    background-color: var(--slate-300);
    cursor: not-allowed;
}

.btn-photo svg {
    width: 18px;
    height: 18px;
}

/* Preview de foto capturada */
.photo-preview-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    width: 100%;
}

.photo-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    overflow: visible;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.photo-thumb:hover {
    transform: scale(1.05);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--emerald-500);
}

.photo-thumb .photo-count {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--slate-700);
    color: var(--white);
    font-size: 0.625rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

/* Footer */
footer {
    background: var(--white);
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--slate-200);
}

.footer-info {
    text-align: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--slate-100);
}

.whatsapp-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #16a34a;
    text-decoration: none;
    transition: color 0.2s ease;
}

.whatsapp-link:hover {
    color: #15803d;
    text-decoration: underline;
}

.whatsapp-link svg {
    flex-shrink: 0;
}

.version-info {
    font-size: 0.75rem;
    color: var(--slate-400);
    margin-top: 0.5rem;
}

.btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    background-color: var(--emerald-500);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--emerald-600);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background-color: var(--slate-300);
    cursor: not-allowed;
}

.btn-primary svg {
    flex-shrink: 0;
}

.btn-secondary {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--slate-700);
    background-color: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: var(--slate-200);
}

.btn-cancel {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--red-500);
    background-color: var(--red-50);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background-color: var(--red-500);
    color: var(--white);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(1);
    transition: transform 0.2s ease;
}

.modal-content h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--slate-900);
    margin-bottom: 1rem;
    text-align: center;
}

/* Container da câmera com botão de flip */
.camera-container {
    position: relative;
    width: 100%;
}

#camera-preview {
    width: 100%;
    border-radius: var(--radius-lg);
    background: var(--slate-900);
    aspect-ratio: 4/3;
    object-fit: cover;
}

/* Preview espelhado para câmera frontal */
#camera-preview.mirrored {
    transform: scaleX(-1);
}

.btn-flip {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-full);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.btn-flip:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.btn-flip:active {
    transform: scale(0.95);
}

#photo-canvas {
    display: none;
}

#photo-preview {
    width: 100%;
    border-radius: var(--radius-lg);
    aspect-ratio: 4/3;
    object-fit: cover;
}

#photo-preview.hidden {
    display: none;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: center;
}

.modal-actions button {
    flex: 1;
    min-width: 100px;
}

.modal-actions button.hidden {
    display: none;
}

/* Modal Viewer (visualização de fotos) */
.viewer-content {
    max-width: 500px;
    padding: 0;
    overflow: hidden;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--slate-200);
}

.viewer-header h3 {
    margin: 0;
    font-size: 1rem;
    text-align: left;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--slate-100);
    border-radius: var(--radius-full);
    font-size: 1.25rem;
    color: var(--slate-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: var(--slate-200);
    color: var(--slate-900);
}

.viewer-image-container {
    background: var(--slate-900);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    max-height: 60vh;
}

.viewer-image-container img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
}

.viewer-nav {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--slate-200);
    background: var(--slate-50);
}

.btn-nav {
    flex: 1;
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--slate-700);
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-nav:hover:not(:disabled) {
    background: var(--slate-100);
}

.btn-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-delete {
    flex: 1;
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--white);
    background: var(--red-500);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: var(--red-600);
}

/* Utilitários */
.hidden {
    display: none !important;
}

/* Responsivo */
@media (min-width: 640px) {
    header {
        padding: 1.25rem 2rem 0;
    }

    .header-logo {
        width: 56px;
        height: 56px;
    }

    header h1 {
        font-size: 1.375rem;
    }

    .progress-bar-container {
        margin: 0 -2rem;
    }

    main {
        padding: 1.5rem;
    }

    .checklist-item-header {
        padding: 1.25rem 1.75rem;
    }

    .photo-area {
        padding: 1rem 1.75rem 1.25rem;
    }

    footer {
        padding: 1.25rem 2rem;
    }
}

/* Animações - apenas na primeira renderização */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.checklist-item.animate-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Scrollbar customizado */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}
