/* Design System & VariÃ¡veis */
:root {
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-surface-hover: #f8fafc;
    --color-border: #cbd5e1;
    --color-primary: #005b9f;
    --color-primary-hover: #004080;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    
    --shadow-glass: 0 1px 3px rgba(0,0,0,0.1);
    --blur-glass: none;
    --radius-lg: 4px;
    --radius-md: 4px;
    --radius-sm: 2px;
    
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Tipografia */
h1, h2, h3 { font-weight: 600; color: #0f172a; }
p { line-height: 1.5; }
.text-muted { color: var(--color-text-muted); font-size: 0.9rem; }

/* Estrutura Principal */
.app-container {
    flex: 1;
    max-width: 95%;
    margin: 0 auto;
    width: 100%;
    padding: 2rem;
    position: relative;
    min-height: calc(100vh - 60px); 
}

/* Glassmorphism Classes (Core) -> Agora Solid/Clean Classes */
.section-glass {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-glass);
    margin-bottom: 1.5rem;
}

/* Esconder vistas (SPA behavior) */
.hidden { display: none !important; }
.view {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Menu de NavegaÃ§Ã£o --- */
nav#main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    background: #ffffff;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-primary);
}
.nav-links { display: flex; gap: 0.5rem; }
.nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.nav-btn:hover { color: var(--color-primary); background: #f1f5f9; }
.nav-btn.active { 
    color: var(--color-primary); 
    background: #e0f2fe; 
    border-color: #bae6fd;
    font-weight: 600;
}
.sub-nav-btn {
    background: transparent; border: 1px solid transparent; color: var(--color-text-muted); font-size: 0.85rem; font-weight: 500; cursor: pointer; padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); transition: var(--transition);
}
.sub-nav-btn:hover { color: var(--color-primary); background: #f1f5f9; }
.sub-nav-btn.active { color: var(--color-primary); background: #ffffff; border-color: #cbd5e1; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

#sub-nav {
    background: #f8fafc; border-bottom: 1px solid var(--color-border); padding: 0.5rem 2rem; position: sticky; top: 60px; z-index: 99; display: flex; justify-content: flex-start;
}
#sub-nav.hidden { display: none !important; }

.nav-user { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; font-weight:500; color: var(--color-text);}

/* --- BotÃµes e Inputs --- */
button { font-family: inherit; }
.btn-primary, .btn-secondary, .btn-logout {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid transparent;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary { background: #f8fafc; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: #f1f5f9; border-color: #94a3b8; }

.btn-logout { background: transparent; border: 1px solid var(--color-border); color: var(--color-danger); padding: 0.4rem 1rem; }
.btn-logout:hover { background: #fef2f2; border-color: #fecaca; }
.w-full { width: 100%; }

.btn-link { background: none; border: none; color: var(--color-primary); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 4px; font-weight: 500;}
.btn-link:hover { color: var(--color-primary-hover); }

/* Inputs Elementos RÃ¡pidos */
.input-group { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1rem; }
.input-group label { font-size: 0.85rem; font-weight: 600; color: var(--color-text); }
.input-group input, .input-group textarea, .input-group select {
    background: #ffffff;
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}
.ts-input {
    width: 68px;
    padding: 2px;
    font-size: 0.8rem;
    text-align: center;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
}
.ts-input:focus { border-color: var(--color-primary); outline: none; }
.ts-clear-btn {
    background: none; border: none; color: #ef4444; cursor: pointer; padding: 2px; font-size: 0.9rem; margin-left: 0px;
}
.ts-clear-btn:hover { background: #fee2e2; border-radius: 3px; }
.ts-btn-save { padding: 4px 8px; font-size: 0.7rem; background: #e2e8f0; border: 1px solid #cbd5e1; border-radius: 4px; cursor: pointer; }
.ts-btn-save:hover { background: #0ea5e9; color: white; border-color: #0284c7; }

/* Reverter o estilo dark do select */
.input-group select { 
    appearance: none; 
    background-image: url('data:image/svg+xml;utf8,<svg fill="%2364748b" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>'); 
    background-repeat: no-repeat; 
    background-position-x: calc(100% - 10px); 
    background-position-y: 50%; 
    padding-right: 30px;
}

/* --- Vista Login --- */
#login-view {
    max-width: 420px;
    margin: 6rem auto;
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.brand-icon {
    color: var(--color-primary);
    margin-bottom: 1rem;
}
.auth-toggle { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; }

/* --- Dashboard / InventÃ¡rio --- */
.header-action { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
.item-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}
.item-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.item-img-wrap {
    width: 100%;
    height: 180px;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--color-border);
}
.item-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.item-card:hover .item-img-wrap img { transform: scale(1.02); }
.status-tag {
    position: absolute;
    top: 10px; right: 10px;
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.status-tag.available { color: var(--color-success); border: 1px solid var(--color-success); }
.status-tag.unavailable { color: var(--color-danger); border: 1px solid var(--color-danger); }
.item-info { padding: 1rem; flex: 1; display: flex; flex-direction: column; }
.item-info h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.item-info p { color: var(--color-text-muted); font-size: 0.85rem; flex: 1; }

/* File Uploader Custom UI */
.file-upload-zone {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}
.file-upload-zone:hover { border-color: var(--color-primary); background: #f0f9ff; }
.file-upload-zone input {
    position: absolute; top:0; left:0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; z-index: 10;
}
.upload-hint {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
}
.upload-hint svg { margin-bottom: 0.5rem; color: var(--color-text-muted); }

/* Form Grids */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.col-span-2 { grid-column: span 2; }
.grid-split { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.grid-2-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

@media (max-width: 768px) {
    /* Grids & Layouts */
    .grid-split, .grid-2-cols { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: auto; }
    
    /* EspaÃ§amentos Globais */
    .app-container { padding: 1rem; }
    .section-glass { padding: 1rem; }
    
    /* NavegaÃ§Ã£o Principal */
    nav#main-nav { padding: 0.75rem 1rem; flex-direction: column; gap: 10px; }
    .nav-brand { width: 100%; justify-content: center; margin-bottom: 5px; }
    .nav-links { flex-wrap: wrap; justify-content: center; width: 100%; }
    .nav-user { width: 100%; justify-content: center; margin-top: 5px; }
    
    /* Sub NavegaÃ§Ã£o */
    #sub-nav { padding: 0.5rem 1rem; flex-wrap: wrap; justify-content: center; gap: 5px; }
    .sub-nav-btn { flex: 1 1 45%; text-align: center; padding: 0.6rem; font-size: 0.9rem; }
    
    /* Headers de SecÃ§Ã£o e BotÃµes de AÃ§Ã£o */
    .header-action { flex-direction: column; align-items: stretch !important; gap: 1rem; }
    .header-action > div { width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: stretch !important; }
    .header-action input, .header-action select, .header-action button { width: 100% !important; box-sizing: border-box; }
    
    /* Tabelas em TelemÃ³vel */
    table th, table td { font-size: 0.8rem !important; padding: 0.5rem !important; }
    
    /* Listas da Escala Home (Dash) */
    #home-schedule-list > div { grid-template-columns: 1fr !important; gap: 10px !important; text-align: center; }
    #home-schedule-list > div > div { border-right: none !important; padding-right: 0 !important; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; }
    #home-schedule-list > div > div:last-child { border-bottom: none; padding-bottom: 0; text-align: center !important; }
    
    /* Modais */
    .zoom-modal-content { max-width: 95%; max-height: 80%; }
    .zoom-modal > div { max-width: 95% !important; padding: 1.5rem 1rem !important; }
    
    /* Toast Notifications */
    .toast-container { right: 10px; left: 10px; bottom: 10px; width: auto; }
}

/* Spinner Loadings */
.spinner-container { text-align: center; padding: 3rem 0; color: var(--color-text-muted); }
.spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast Notifications */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #ffffff;
    border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary);
    padding: 1rem; border-radius: var(--radius-sm); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: toastSlide 0.3s ease-out;
    color: var(--color-text);
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }
@keyframes toastSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Rentals List */
.rentals-list { display: flex; flex-direction: column; gap: 0.5rem; }
.rental-card { padding: 0.75rem; background: #f8fafc; border: 1px solid var(--color-border); border-radius: var(--radius-sm); border-left: 3px solid var(--color-primary); }
.rental-card h4 { margin-bottom: 0.25rem; font-size: 0.95rem; }
.rental-card .dates { font-size: 0.8rem; color: var(--color-text-muted); }

/* Badges de Status (Ex: Disponibilidade) */
.status-badge { padding: 0.25rem 0.5rem; border-radius: 2px; font-size: 0.8rem; font-weight: 600; display: inline-block; border: 1px solid transparent; }
.status-badge.red { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.status-badge.green { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.status-badge.blue { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.mt-2 { margin-top: 0.5rem;} .mt-3 { margin-top: 0.75rem;} .mt-4 { margin-top: 1rem; }

.admin-only-inline { display: none; }
.admin-mode .admin-only-inline { display: inline-flex; }

/* Category Filters */
.category-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-bottom: 0.5rem;
}
.cat-btn {
    background: #ffffff;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 0.3rem 0.8rem;
    border-radius: 100px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}
.cat-btn:hover { background: #f1f5f9; color: var(--color-text); }
.cat-btn.active {
    background: #e0f2fe;
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
}

/* Tabelas ClÃ¡ssicas ERP */
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}
table th {
    background: #f1f5f9;
    color: var(--color-text);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--color-border);
    border-top: 1px solid var(--color-border);
}
table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
table tbody tr:hover {
    background-color: #f8fafc;
}
table tbody tr:nth-child(even) {
    background-color: #fafafa;
}
table tbody tr:nth-child(even):hover {
    background-color: #f8fafc;
}

/* Image Zoom Modal */
.zoom-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(30, 41, 59, 0.9);
    justify-content: center;
    align-items: center;
}
.zoom-modal.active { display: flex; animation: fadeIn 0.2s; }
.zoom-modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    animation: zoomIn 0.2s forwards;
    background: white;
}
@keyframes zoomIn {
    to { transform: scale(1); }
}
.zoom-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f8fafc;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
.zoom-close:hover { color: #cbd5e1; }
.zoomable-img { cursor: zoom-in; transition: transform 0.2s; }
.zoomable-img:hover { opacity: 0.9; }

/* Utilities adicionais */
.badge-ini { background: #fef08a; color: #854d0e; border: 1px solid #fde047; padding: 2px 6px; border-radius: 2px; font-weight:600; font-size:0.75rem; }
.badge-ved { background: #bbf7d0; color: #166534; border: 1px solid #86efac; padding: 2px 6px; border-radius: 2px; font-weight:600; font-size:0.75rem; }
.badge-def { background: #bfdbfe; color: #1e40af; border: 1px solid #93c5fd; padding: 2px 6px; border-radius: 2px; font-weight:600; font-size:0.75rem; }
.badge-fal { background: #fecaca; color: #991b1b; border: 1px solid #fca5a5; padding: 2px 6px; border-radius: 2px; font-weight:600; font-size:0.75rem; }

/* RestriÃ§Ãµes de Acesso (RBAC UI) */
.admin-only { display: none !important; }
body.role-admin .admin-only { display: inline-block !important; }



.programador-only { display: none !important; }
body.role-programador .programador-only { display: inline-flex !important; }


/* ==========================================
   Módulo: Produção e Manutenção
   ========================================== */
.prod-ot-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid #bae6fd;
    display: inline-block;
}

.prod-status-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
}
.prod-status-tag.pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.prod-status-tag.completed {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.prod-check-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.prod-check-btn:hover {
    border-color: #10b981;
    color: #059669;
    background: #f0fdf4;
    transform: translateY(-1px);
}
.prod-check-btn.completed {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}
.prod-check-btn.completed:hover {
    background: #059669;
    border-color: #059669;
}

.prod-checkbox-large {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #10b981;
}

.prod-table th, .prod-table td {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    vertical-align: middle;
}
.prod-table th {
    background-color: #f8fafc;
    color: #334155;
    font-weight: 600;
}
.prod-table tr:hover td {
    background-color: #f8fafc;
}
.prod-table tr.row-completed td {
    background-color: #fcfdfd;
}

.prod-count-badge {
    background: #e2e8f0;
    color: #334155;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 5px;
}
.res-tab-btn.active .prod-count-badge {
    background: var(--color-primary);
    color: #ffffff;
}

/* Tabela de Linhas de Produção / Manutenção */
.prod-line-table th {
    background: #f1f5f9;
    padding: 8px 10px;
    font-size: 0.8rem;
    color: #475569;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    text-transform: uppercase;
}
.prod-line-table td {
    padding: 6px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}
.prod-line-table input {
    width: 100%;
    padding: 7px 10px;
    font-size: 0.9rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.prod-line-table input:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 91, 159, 0.15);
}

/* Badge Carpintaria */
.badge-carpentry {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
