:root {
    --primary-color: #00cc44;
    --border-color: #ccc;
    --bg-color: #f9f9f9;
}

html, body {
    height: 100%;
    height: -webkit-fill-available; /* Essencial para iPhones */
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-color);
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 15px;
}

/* Cabeçalho Superior Fixo */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
    flex-shrink: 0;
}

.app-header h1 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.admin-toggle-btn {
    background-color: #666;
    color: white;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
}
.admin-toggle-btn.editing {
    background-color: #ff9900;
}

/* Painel do Criador Retrátil */
.creator-panel {
    display: none;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border: 2px dashed #ff9900;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.creator-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    min-width: 180px;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 13px;
}

input[type="text"], input[type="file"] {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
}

.panel-sections-container {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    flex: 2;
    min-width: 280px;
}

.backup-actions {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 180px;
}

button.action-btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#addCardBtn { background-color: var(--primary-color); }
#addCardBtn:hover { background-color: #00aa38; }
#clearBoardBtn { background-color: #ff3333; }
#clearBoardBtn:hover { background-color: #cc0000; }

.backup-btn { background-color: #4a90e2; }
.backup-btn:hover { background-color: #357abd; }

button:disabled {
    background-color: #aaa !important;
    cursor: not-allowed;
}

#importFile { display: none; }

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

.parental-box {
    background: white;
    padding: 25px;
    border-radius: 15px;
    width: 320px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
}

.parental-box h4 { margin: 0 0 8px 0; font-size: 16px; color: #333; }
.parental-box p { margin: 0 0 15px 0; font-size: 13px; color: #666; }

.slider-track {
    position: relative;
    background: #eee;
    padding: 2px;
    border-radius: 25px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid #ddd;
}

.slider-label {
    position: absolute;
    font-size: 13px;
    font-weight: bold;
    color: #999;
    pointer-events: none;
    user-select: none;
}

.ios-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 100%;
    background: transparent;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    cursor: pointer;
    z-index: 5;
}

.ios-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 50px;
    height: 40px;
    border-radius: 20px;
    background: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.ios-slider::-moz-range-thumb {
    width: 50px;
    height: 40px;
    border: none;
    border-radius: 20px;
    background: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.close-modal-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    color: #aaa;
    cursor: pointer;
}

/* --- LAYOUT DINÂMICO INTELIGENTE --- */
.main-layout {
    display: flex;
    gap: 15px;
    align-items: stretch;
    flex-grow: 1;
    overflow: hidden;
}

/* Painel Lateral Compacto Mantido */
.sidebar-tabs {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 15px 10px;
    width: 150px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tab-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    width: 100%;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.tab-row:hover {
    background: #f0f0f0;
}

.tab-bullet {
    font-size: 20px;
    margin-right: 6px;
    line-height: 1;
    color: var(--primary-color);
}

.tab-item {
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    color: #333;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-item.active {
    color: var(--primary-color);
    font-size: 25px;
}

.delete-board-btn {
    background: none;
    border: none;
    color: #ff3333;
    font-size: 16px;
    cursor: pointer;
    padding: 0 3px;
}

/* Chassi Principal Fluido */
.board-chassis {
    flex-grow: 1;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.board-header {
    display: none;
}

/* Container de Enquadramento */
.scroll-frame {
    display: flex;
    gap: 10px;
    flex-grow: 1;
    overflow: hidden;
    justify-content: center;
    align-items: center;
}

/* Grade Inteligente Automática */
.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px; /* Reduzido para dar mais espaço */
    width: 100%;
    height: 100%;
    /* Removemos restrições rígidas para deixar o flexbox/grid decidir */
}

.grid-slot {
    border: 2px dashed #e0e0e0;
    background: #fafafa;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    position: relative;
    overflow: hidden; /* Isso impede que o texto saia para fora */
}

.delete-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ff3333;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    font-weight: bold;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}

.grid-slot.edit-active {
    border: 2px dashed #ff9900;
    background: #fff9e6;
    animation: slight-shake 0.3s infinite alternate;
}

@keyframes slight-shake {
    0 { transform: rotate(-0.5deg); }
    100% { transform: rotate(0.5deg); }
}

/* Cards Proporcionais */
.aac-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centraliza o conjunto todo */
    align-items: center;
    overflow: hidden;
}

.aac-card h3 {
    margin: 0;
    padding: 2px;
    font-size: 10px; /* Tamanho base menor */
    line-height: 1;
    white-space: nowrap;
    text-overflow: ellipsis; /* Adiciona "..." se o texto for muito longo */
    width: 100%;
    text-align: center;
}

.aac-card img {
    max-height: 60%; /* Deixa mais espaço para o texto */
    width: auto;
    object-fit: contain;
}

.aac-card:active {
    transform: scale(0.95);
    border-color: var(--primary-color);
    box-shadow: 0 0 12px rgba(0, 204, 68, 0.5);
}

.side-scroll-bar { display: none; }

.rtl-layout { direction: rtl; }
.rtl-layout .delete-board-btn { margin-left: 0; margin-right: auto; }
.rtl-layout .tab-bullet { margin-right: 0; margin-left: 10px; }
