/* ContPalma - Frontend Operador - Estilos */

/* === VARIÁVEIS === */
:root {
    --primary: #0B6E4F;
    --primary-light: #0d8a63;
    --primary-dark: #095a41;
    --secondary: #FFD166;
    --accent: #118AB2;
    --error: #EF476F;
    --success: #06D6A0;
    --warning: #FFA62B;
    
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --text: #212529;
    --text-secondary: #6C757D;
    --border: #DEE2E6;
    
    --radius: 16px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* === LAYOUT === */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: block;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.header p {
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

/* === LOGO (LOGIN) === */
.logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 8px 0;
}

.logo p {
    font-size: 18px;
    color: var(--text-secondary);
}

/* === CARDS === */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--primary);
}

.card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

/* === FORMULÁRIOS === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: var(--font);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* === RADIO BUTTONS === */
.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-label span {
    font-weight: 500;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--primary);
}

.radio-label:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: rgba(11, 110, 79, 0.05);
}

/* === BOTÕES === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 18px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

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

.btn-success:hover:not(:disabled) {
    background: #05c291;
}

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

.btn-danger:hover:not(:disabled) {
    background: #e8385f;
}

/* === BOTÕES DE CONTAGEM RÁPIDA === */
.quick-count-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.btn-quick-count {
    padding: 20px;
    background: var(--secondary);
    border: none;
    border-radius: var(--radius);
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.btn-quick-count:hover {
    background: #ffdc80;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-quick-count:active {
    transform: translateY(0);
}

/* === STATS CARDS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

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

.stat-icon {
    font-size: 32px;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.stat-value.small {
    font-size: 18px;
}

.stat-primary {
    border-left: 4px solid var(--primary);
}

.stat-secondary {
    border-left: 4px solid var(--secondary);
}

.stat-accent {
    border-left: 4px solid var(--accent);
}

.stat-info {
    border-left: 4px solid var(--text-secondary);
}

/* === OPERADOR INFO === */
.operator-info {
    text-align: center;
    padding: 20px 0;
}

.operator-info h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.operator-info p {
    color: var(--text-secondary);
}

/* === CONTAGENS RECENTES === */
.recent-counts {
    max-height: 300px;
    overflow-y: auto;
}

.count-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.count-item:last-child {
    border-bottom: none;
}

.count-info {
    flex: 1;
}

.count-time {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.count-details {
    font-size: 16px;
    font-weight: 600;
}

.count-badge {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 0;
}

/* === MODAL === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--text);
}

.modal-content p {
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* === LOADING === */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    margin-top: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    z-index: 3000;
    transition: bottom 0.3s;
    max-width: 90%;
}

.toast.show {
    bottom: 20px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

/* === MENSAGENS DE ERRO === */
.error-message {
    background: rgba(239, 71, 111, 0.1);
    border: 2px solid var(--error);
    border-radius: var(--radius);
    padding: 12px 16px;
    color: var(--error);
    font-weight: 500;
    margin-top: 16px;
}

/* === FOOTER === */
.footer {
    text-align: center;
    margin-top: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

.status-online {
    color: var(--success);
    font-weight: 600;
}

.status-offline {
    color: var(--error);
    font-weight: 600;
}

/* === RESPONSIVO === */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .quick-count-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 12px;
    }
    
    .card {
        padding: 16px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .logo h1 {
        font-size: 36px;
    }
}

/* === YOLO HEALTH STATUS === */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.health-checking {
    background: rgba(255, 166, 43, 0.15);
    color: var(--warning);
}

.health-checking .health-dot {
    background: var(--warning);
}

.health-online {
    background: rgba(6, 214, 160, 0.15);
    color: var(--success);
}

.health-online .health-dot {
    background: var(--success);
}

.health-offline {
    background: rgba(239, 71, 111, 0.15);
    color: var(--error);
}

.health-offline .health-dot {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* === YOLO WARNING PANEL === */
.warning-panel {
    background: linear-gradient(135deg, rgba(255, 166, 43, 0.12) 0%, rgba(255, 166, 43, 0.06) 100%);
    border: 2px solid var(--warning);
    border-left: 6px solid var(--warning);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(255, 166, 43, 0.15);
    animation: slideDown 0.3s ease-out;
}

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

.warning-icon {
    font-size: 36px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.warning-content {
    flex: 1;
}

.warning-content h4 {
    margin: 0 0 10px 0;
    color: #d97706;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.warning-main-message {
    margin: 0 0 12px 0 !important;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
}

.warning-details {
    margin: 0 !important;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 166, 43, 0.25);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.warning-details strong {
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
}

.btn-warning-dismiss {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-warning-dismiss:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
}

/* === STAT BREAKDOWN (Auto + Manual) === */
.stat-breakdown {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 12px;
    color: var(--text-secondary);
}

.stat-auto, .stat-manual {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-auto strong, .stat-manual strong {
    color: var(--text);
    font-size: 14px;
}

/* === CAMERAS GRID === */
.cameras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.camera-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.camera-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

.camera-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.camera-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.camera-preview {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
    background: #000;
    overflow: hidden;
}

.camera-preview img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.camera-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    text-align: center;
}

.camera-stats {
    padding: 12px 16px;
    background: rgba(11, 110, 79, 0.05);
    display: flex;
    justify-content: space-around;
    border-top: 2px solid var(--border);
}

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

.camera-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.camera-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.camera-error {
    padding: 16px;
    text-align: center;
    color: var(--error);
    font-size: 13px;
}

/* === RESPONSIVE CAMERAS === */
@media (max-width: 768px) {
    .cameras-grid {
        grid-template-columns: 1fr;
    }
    
    .warning-panel {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-breakdown {
        flex-direction: column;
        gap: 8px;
    }
}
