/* ==========================================================================
   ATELIER BY JULY - TRUE NEON & GLASS SAAS V1.0 (MASTER EDITION)
   ========================================================================== */

:root { 
    --success: #22c55e; 
    --danger: #ef4444; 
    --primary: #00e5ff;
    --primary-glow: rgba(0, 229, 255, 0.4);
    --bg: #030712;
    --glass: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #ffffff;
    --text-dim: #94a3b8;
}

/* === OS 16 TEMAS (ESCUROS E CLAROS) === */
[data-theme="sky"] { --primary: #00e5ff; --primary-glow: rgba(0, 229, 255, 0.4); --bg: #030712; }
[data-theme="emerald"] { --primary: #00ff88; --primary-glow: rgba(0, 255, 136, 0.4); --bg: #022c22; }
[data-theme="purple"] { --primary: #a855f7; --primary-glow: rgba(168, 85, 247, 0.4); --bg: #2e1065; }
[data-theme="orange"] { --primary: #f59e0b; --primary-glow: rgba(245, 158, 11, 0.4); --bg: #451a03; }
[data-theme="pink"] { --primary: #ec4899; --primary-glow: rgba(236, 72, 153, 0.4); --bg: #4c0519; }

[data-theme="liquid-ocean"] { --primary: #0ea5e9; --primary-glow: rgba(14, 165, 233, 0.5); --bg: #082f49; }
[data-theme="liquid-magma"] { --primary: #ef4444; --primary-glow: rgba(239, 68, 68, 0.5); --bg: #450a0a; }
[data-theme="liquid-toxic"] { --primary: #84cc16; --primary-glow: rgba(132, 204, 22, 0.5); --bg: #14532d; }
[data-theme="liquid-nebula"] { --primary: #d946ef; --primary-glow: rgba(217, 70, 239, 0.5); --bg: #312e81; }

[data-theme="glass-frost"] { --primary: #cbd5e1; --primary-glow: rgba(203, 213, 225, 0.2); --bg: #0f172a; }
[data-theme="glass-obsidian"] { --primary: #94a3b8; --primary-glow: rgba(148, 163, 184, 0.2); --bg: #000000; }
[data-theme="glass-ruby"] { --primary: #f43f5e; --primary-glow: rgba(244, 63, 94, 0.2); --bg: #2a0a18; }
[data-theme="glass-sapphire"] { --primary: #60a5fa; --primary-glow: rgba(96, 165, 250, 0.2); --bg: #0a192f; }

/* ☀️ TEMAS CLAROS */
[data-theme="light-clean"] { --primary: #0284c7; --primary-glow: rgba(2, 132, 199, 0.2); --bg: #f8fafc; --glass: rgba(255, 255, 255, 0.75); --glass-border: rgba(0, 0, 0, 0.1); --text: #0f172a; --text-dim: #475569; }
[data-theme="light-pearl"] { --primary: #9333ea; --primary-glow: rgba(147, 51, 234, 0.2); --bg: #faf5ff; --glass: rgba(255, 255, 255, 0.75); --glass-border: rgba(0, 0, 0, 0.1); --text: #3b0764; --text-dim: #581c87; }
[data-theme="light-mint"] { --primary: #059669; --primary-glow: rgba(5, 150, 105, 0.2); --bg: #f0fdf4; --glass: rgba(255, 255, 255, 0.75); --glass-border: rgba(0, 0, 0, 0.1); --text: #064e3b; --text-dim: #065f46; }

/* REGRAS TEMA CLARO */
body[data-theme^="light"] .form-input { background: rgba(255,255,255,0.8); color: #0f172a; border-color: rgba(0,0,0,0.1); }
body[data-theme^="light"] .form-input:focus { box-shadow: 0 0 10px var(--primary-glow); }
body[data-theme^="light"] .login-header h1, body[data-theme^="light"] .logo-text, body[data-theme^="light"] #display-nome-atelier { color: #0f172a !important; }
body[data-theme^="light"] .nav-link:hover { background: rgba(0,0,0,0.05); color: var(--primary); }
body[data-theme^="light"] .nav-link.active { background: rgba(0,0,0,0.05); }
body[data-theme^="light"] .glass-panel { box-shadow: 0 15px 45px rgba(0,0,0,0.05); }


/* RESET E BASE */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }
body { background: var(--bg); color: var(--text); min-height: 100vh; overflow-y: auto; overflow-x: hidden; position: relative; transition: background 0.5s ease; }

/* GLOW E ESFERAS NEON */
body::before { content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; background: radial-gradient(circle at 20% 20%, var(--primary-glow) 0%, transparent 40%), radial-gradient(circle at 80% 80%, var(--primary-glow) 0%, transparent 40%); filter: blur(80px); animation: moveGlow 15s ease-in-out infinite alternate; pointer-events: none;}
@keyframes moveGlow { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.2); opacity: 0.8; } }
.area { position: fixed; width: 100%; height: 100%; z-index: -1; top: 0; left: 0; pointer-events: none; overflow: hidden; }
.circles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.circles li { position: absolute; display: block; list-style: none; width: 20px; height: 20px; background: var(--primary-glow); box-shadow: 0 0 20px var(--primary); animation: animateCircles 25s linear infinite; bottom: -150px; border-radius: 50%; }
.circles li:nth-child(1){left:25%; width:80px; height:80px; animation-delay:0s;}
.circles li:nth-child(2){left:10%; width:20px; height:20px; animation-delay:2s; animation-duration:12s;}
.circles li:nth-child(3){left:70%; width:20px; height:20px; animation-delay:4s;}
.circles li:nth-child(4){left:40%; width:60px; height:60px; animation-delay:0s; animation-duration:18s;}
.circles li:nth-child(5){left:65%; width:20px; height:20px; animation-delay:0s;}
.circles li:nth-child(6){left:75%; width:110px; height:110px; animation-delay:3s;}
@keyframes animateCircles { 0% { transform: translateY(0) rotate(0deg); opacity: 1; border-radius: 50%; } 100% { transform: translateY(-1000px) rotate(720deg); opacity: 0; border-radius: 20%; } }

/* LOGIN SCREEN */
#login-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-box { width: 100%; max-width: 400px; padding: 45px; text-align: center; background: var(--glass); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); border: 1px solid var(--glass-border); border-radius: 30px; box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), 0 0 20px var(--primary-glow); animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.login-header h1 { font-size: 28px; font-weight: 900; margin-bottom: 5px; color: #fff; }
.login-header h1 span { color: var(--primary); text-shadow: 0 0 15px var(--primary-glow); }
.login-header p { color: var(--text-dim); font-size: 14px; margin-bottom: 30px; }
.input-wrapper { margin-bottom: 15px; text-align: left; }
.input-wrapper label { font-size: 10px; font-weight: 800; color: var(--primary); text-transform: uppercase; margin-left: 5px; }
.form-input { width: 100%; background: rgba(0,0,0,0.4); border: 1px solid var(--glass-border); padding: 14px; border-radius: 14px; color: var(--text); outline: none; margin-top: 5px; transition: 0.3s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 15px var(--primary-glow); }
.login-btn { width: 100%; padding: 16px; background: var(--primary); color: #000; border: none; border-radius: 14px; font-weight: 800; font-size: 16px; cursor: pointer; transition: 0.3s; margin-top: 10px; box-shadow: 0 0 20px var(--primary-glow); display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-btn:hover { transform: translateY(-3px); filter: brightness(1.2); box-shadow: 0 0 30px var(--primary); }
.separator { margin: 20px 0; color: var(--text-dim); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.google-btn { width: 100%; padding: 14px; background: #fff; color: #000; border: none; border-radius: 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: 0.3s; }
.google-btn:hover { background: #f1f1f1; transform: scale(1.02); }

/* LAYOUT DO APP (CLEAN iOS FLUTUANTE) */
#app { display: flex; min-height: 100vh; padding: 20px; gap: 20px; align-items: flex-start; }
aside { width: 280px; display: flex; flex-direction: column; padding: 20px 15px; position: sticky; top: 20px; height: calc(100vh - 40px); overflow-y: auto; scrollbar-width: none; }
aside::-webkit-scrollbar { display: none; }
main { flex: 1; padding: 35px; min-height: calc(100vh - 40px); }
.glass-panel { background: var(--glass); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); border: 1px solid var(--glass-border); border-radius: 24px; box-shadow: 0 15px 45px rgba(0,0,0,0.2); }
.logo-container { text-align: center; margin-bottom: 25px; }
.logo-text { font-size: 26px; font-weight: 800; }
.logo-text span { color: var(--primary); text-shadow: 0 0 20px var(--primary-glow); }
.nav-cap { font-size: 10px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; margin: 15px 0 5px 10px; display: block; }
.nav-link { display: flex; align-items: center; gap: 12px; color: var(--text-dim); text-decoration: none; padding: 10px 15px; border-radius: 14px; margin-bottom: 2px; font-weight: 600; font-size: 13px; transition: 0.4s ease; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: var(--text); transform: translateX(5px); }
.nav-link.active { background: rgba(255,255,255,0.05); color: var(--primary); border: 1px solid var(--glass-border); box-shadow: 0 0 15px var(--primary-glow); }
.logout-btn { margin-top:auto; background:none; border:none; color:var(--danger); cursor:pointer; font-weight:800; display:flex; align-items:center; gap:10px; padding: 10px 15px; transition: 0.3s;}
.logout-btn:hover { transform: translateX(5px); filter: brightness(1.2); }
.btn-primary { background: var(--primary); color: #000; border: none; padding: 12px 24px; border-radius: 14px; font-weight: 800; cursor: pointer; transition: 0.3s; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.2); box-shadow: 0 5px 15px var(--primary-glow); }

/* UTILITÁRIOS & DROPDOWNS */
select.form-select option { background-color: #0f172a; color: #ffffff; padding: 10px; }
body[data-theme^="light"] select.form-select option { background-color: #ffffff; color: #0f172a; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 10px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; margin-bottom: 8px; }

/* MODAIS CLEAN (FULL PAGE, SEM SOBREPOSIÇÃO) */
.modal-overlay, [id$="-modal"], #modal-pedido, #modal-material, #modal-tarefa {
    display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg); z-index: 9999; overflow-y: auto; padding: 30px;
}
.modal-content, .form-container {
    background: var(--glass); border: 1px solid var(--glass-border); border-radius: 24px;
    padding: 35px; max-width: 1000px; margin: 0 auto; position: relative; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.close-modal, .fa-xmark {
    position: absolute; top: 25px; right: 30px; cursor: pointer; color: var(--danger);
    font-size: 24px; transition: 0.2s; background: rgba(239, 68, 68, 0.1); padding: 5px 12px; border-radius: 8px;
}
.close-modal:hover, .fa-xmark:hover { transform: scale(1.1); background: var(--danger); color: white; }
/* ==========================================================================
   RESTAURAÇÃO: UTILITÁRIOS, TABELAS E DASHBOARD
   ========================================================================== */

/* Efeito de clique/hover nos cartões do Dashboard */
.card-clicavel, .dashboard-card, [onclick] {
    cursor: pointer !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.card-clicavel:hover, .dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px var(--primary-glow) !important;
    filter: brightness(1.1);
    border-color: var(--primary) !important;
}

/* Correção para Inputs Genéricos (Calculadora e outros) */
input[type="text"], input[type="number"], input[type="date"], input[type="time"] {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text);
    outline: none;
    transition: 0.3s;
}
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}
body[data-theme^="light"] input[type="text"], 
body[data-theme^="light"] input[type="number"], 
body[data-theme^="light"] input[type="date"], 
body[data-theme^="light"] input[type="time"] {
    background: rgba(255,255,255,0.8);
    color: #0f172a;
    border-color: rgba(0,0,0,0.1);
}

/* Restauração das Tabelas e Listas de Pedidos */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}
th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    font-size: 13px;
}
th {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* Botões de Ação das Tabelas (Abrir Pedido, Exportar, etc.) */
.btn-icon, .btn-action, .btn-export, .btn-sm {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 12px;
}
.btn-icon:hover, .btn-action:hover, .btn-export:hover, .btn-sm:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    transform: translateY(-2px);
}

/* Badges (Estado do Pedido) */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}
/* ==========================================================================
   RESTAURAÇÃO: CALCULADORA DE LUCRO E CARDS GENÉRICOS
   ========================================================================== */

/* Layout de Grelha para a Calculadora */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* O "Card" que envolve os campos e os resultados */
.card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* Garante que as caixas de texto ficam com a cor correta em todos os temas */
.card .input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text);
    outline: none;
    transition: 0.3s;
    margin-top: 8px;
}

.card .input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

body[data-theme^="light"] .card .input {
    background: rgba(255,255,255,0.8);
    color: #0f172a;
    border-color: rgba(0,0,0,0.1);
}

/* Estilo do Cabeçalho da Vista */
.header-area h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 5px;
}

.header-area p {
    color: var(--text-dim);
    font-size: 14px;
}

/* Ajuste Responsivo para telas pequenas (telemóveis/tablets) */
@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}
/* ==========================================================================
   CORREÇÃO: FUNDOS E RESPONSIVIDADE TOTAL (MOBILE)
   ========================================================================== */

/* 1. Corrige o fundo dos Modais (Pedidos e Calculadora) para abraçarem todo o conteúdo */
.modal-overlay, [id$="-modal"] {
    align-items: flex-start !important; /* Faz a janela começar no topo e crescer para baixo */
    padding: 30px 15px !important;
}
.modal-content, .form-container {
    height: auto !important;
    min-height: min-content !important;
    overflow: visible !important; /* Deixa a página rolar naturalmente */
    margin-bottom: 40px !important; /* Dá um respiro no fundo do ecrã */
}

/* 2. MÁGICA DO TELEMÓVEL: Quando o ecrã for menor que 850px, adapta tudo! */
@media (max-width: 850px) {
    /* O Menu Lateral passa para o topo e deixa de espremer o ecrã */
    #app {
        flex-direction: column !important;
        padding: 10px !important;
    }
    aside {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        top: 0 !important;
        padding: 15px !important;
        margin-bottom: 10px;
    }
    main {
        padding: 15px !important;
        min-height: auto !important;
    }

    /* Parte o ecrã ao meio: Formulários em cima, Resumo em baixo */
    div[style*="grid-template-columns: 1.5fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    .grid-2 {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }

    /* Os inputs que estavam lado a lado passam a ficar um debaixo do outro */
    .form-grid-2, .form-grid-3 {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* O Resumo (que ficava preso ao fazer scroll no PC) solta-se no telemóvel */
    div[style*="position: sticky"] {
        position: relative !important;
        top: auto !important;
    }

    /* Ajuste de botões e tamanhos de letra para dedos */
    .btn-primary {
        width: 100% !important;
        justify-content: center !important;
    }
    .header-area h1 { font-size: 24px !important; }
}
/* ==========================================================================
   NOTIFICAÇÕES (TOASTS) E ALERTAS GLOBAIS DA AGENDA
   ========================================================================== */
#toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 99999;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    background: var(--glass); backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border); border-left: 4px solid var(--success);
    color: var(--text); padding: 15px 20px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); font-size: 13px; font-weight: 800;
    animation: slideInRight 0.3s ease forwards;
}
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: #f59e0b; }

@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Alerta Global Flutuante da Agenda */
#alerta-agenda-global {
    position: fixed; bottom: 30px; right: 30px; z-index: 9999;
    background: var(--primary); color: #000; padding: 15px 25px;
    border-radius: 30px; font-weight: 800; font-size: 14px;
    box-shadow: 0 10px 30px var(--primary-glow); cursor: pointer;
    display: none; align-items: center; gap: 10px;
    animation: pulseAlert 2s infinite;
}
@keyframes pulseAlert { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
/* ==========================================================================
   CORES DOS ESTADOS (PEDIDOS E AGENDA)
   ========================================================================== */
.badge-clickable {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
}

/* Efeito ao passar o rato por cima */
.badge-clickable:hover {
    filter: brightness(1.3);
    transform: scale(1.05);
}

/* PAGAMENTOS */
.b-pago { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid #10b981; }
.b-apagar { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid #ef4444; }

/* ESTADO DE PRODUÇÃO / AGENDA */
.b-pendente { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid #f59e0b; } /* Laranja */
.b-producao { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid #38bdf8; } /* Azul */
.b-concluido { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid #10b981; } /* Verde */


/* ==========================================================================
   BARRA DE ROLAGEM INVISÍVEL (PARA 100+ ITENS)
   ========================================================================== */
/* Respondendo à sua dúvida: Se tiver 100 itens, o ecrã NÃO VAI crescer infinitamente.
   A lista vai ter um tamanho máximo e ganha um scroll interno elegante. */
   
#lista-pedidos, #lista-agenda, #lista-inv {
    max-height: 60vh; /* A lista nunca passa de 60% da altura do ecrã */
    overflow-y: auto; /* Cria o scroll automaticamente se passar do limite */
    padding-right: 5px;
}

/* Deixa a barra de scroll fininha e moderna (estilo Mac/Mobile) */
#lista-pedidos::-webkit-scrollbar, 
#lista-agenda::-webkit-scrollbar, 
#lista-inv::-webkit-scrollbar {
    width: 6px;
}
#lista-pedidos::-webkit-scrollbar-track, 
#lista-agenda::-webkit-scrollbar-track, 
#lista-inv::-webkit-scrollbar-track {
    background: transparent;
}
#lista-pedidos::-webkit-scrollbar-thumb, 
#lista-agenda::-webkit-scrollbar-thumb, 
#lista-inv::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
/* CORES DOS ESTADOS (PEDIDOS E AGENDA) */
.badge-clickable {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.2s;
    display: inline-block;
}
.badge-clickable:hover { transform: scale(1.05); filter: brightness(1.2); }

.b-pago { background: rgba(16, 185, 129, 0.15) !important; color: #10b981 !important; border: 1px solid #10b981 !important; }
.b-apagar { background: rgba(239, 68, 68, 0.15) !important; color: #ef4444 !important; border: 1px solid #ef4444 !important; }

.b-pendente { background: rgba(245, 158, 11, 0.15) !important; color: #f59e0b !important; border: 1px solid #f59e0b !important; }
.b-producao { background: rgba(56, 189, 248, 0.15) !important; color: #38bdf8 !important; border: 1px solid #38bdf8 !important; }
.b-concluido { background: rgba(16, 185, 129, 0.15) !important; color: #10b981 !important; border: 1px solid #10b981 !important; }