/* ================================================= */
/* 0. Configuração Global e Variáveis CSS (Estáticas)*/
/* ================================================= */
:root {
    /* ESQUEMA DE CORES COM GRADIENTE ESTÁTICO */
    --primary-color: #007bff; 
    --gradient-start: #041066; 
    --gradient-end: #491ccb;   
    
    --text-color: #343a40; 
    --main-text-color: #ffffff; /* Cor principal do texto (Branco) */
    
    --sidebar-bg: rgba(255, 255, 255, 0.1); /* Fundo semi-transparente */
    --sidebar-link-hover: rgba(255, 255, 255, 0.2); 
    --sidebar-text-color: #ffffff; /* Cor do texto da sidebar */

    --secondary-color: #28a745; 
    --accent-color: #ffc107; 
    --card-bg: #ffffff; 
    --shadow-deep: 0 10px 30px rgba(0, 0, 0, 0.15); 
    --shadow-card: 0 5px 15px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

body {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; 
}

/* Scrollbar Style Global */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #e9ecef;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* ------------------------------------------------- */
/* HUB HEADER */
/* ------------------------------------------------- */
.hub-header {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 20px 20px;
}

.main-title {
    font-size: 4rem; 
    font-weight: 800;
    text-align: left; 
    margin-bottom: 5px; 
    color: var(--main-text-color); 
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); 
}

.add-button-section {
    text-align: left; 
    margin-bottom: 20px;
}

.add-link-button {
    background-color: var(--main-text-color); 
    color: var(--gradient-end); 
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4); 
}

.add-link-button:hover {
    background-color: #eeeeee;
}

/* ------------------------------------------------- */
/* Formulário */
/* ------------------------------------------------- */
.form-container {
    background: var(--card-bg); 
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-deep);
    width: 100%;
    max-width: 600px;
    margin: 20px auto; 
    border: 1px solid #e9ecef;
    transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out, padding 0.4s ease-in-out, margin 0.4s ease-in-out;
    overflow: hidden; 
    max-height: 500px; 
    opacity: 1;
}

.form-hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    opacity: 0;
}

.form-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--text-color);
    border-left: 5px solid var(--primary-color);
    padding-left: 15px;
}

.app-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input[type="text"], input[type="file"], input[type="url"] {
    border: 1px solid #ced4da;
    padding: 14px;
    border-radius: 8px;
    transition: all 0.3s;
    background-color: #fff;
    font-size: 1rem;
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.4);
    outline: none;
}

.submit-button {
    background-color: var(--primary-color);
    color: white;
    padding: 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    transition: background-color 0.3s, transform 0.1s;
    margin-top: 10px;
}

.submit-button:hover {
    background-color: #0056b3; 
}

.submit-button:active {
    transform: scale(0.99);
}

/* ================================================= */
/* 2. LAYOUT PRINCIPAL (Sidebar + Conteúdo) */
/* ================================================= */

.layout-container {
    display: flex;
    flex-grow: 1;
    width: 100%;
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 20px; 
}

/* ------------------------------------------------- */
/* BARRA LATERAL (SIDEBAR) */
/* ------------------------------------------------- */
.sidebar {
    width: 250px; 
    min-width: 250px;
    background-color: var(--sidebar-bg); 
    padding: 20px 0;
    margin-right: 30px; 
    border-radius: 15px; 
    height: fit-content; 
    position: sticky; 
    top: 20px; 
    align-self: flex-start; 
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.sidebar-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--sidebar-text-color);
    padding: 0 20px 10px 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.sidebar-nav-list {
    list-style: none;
}

.sidebar-nav-item a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--sidebar-text-color);
    font-weight: 500;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-nav-item a:hover {
    background-color: var(--sidebar-link-hover);
    border-left: 5px solid var(--accent-color); 
    padding-left: 15px;
}

/* ------------------------------------------------- */
/* CONTEÚDO PRINCIPAL E GRID DE CATEGORIAS */
/* ------------------------------------------------- */
.content-area {
    flex-grow: 1; 
    padding: 0; 
    min-width: 0; 
}

.categories-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px; 
    padding: 20px 0;
}

/* --- ESTILO DO CARTÃO DE CATEGORIA PRINCIPAL --- */
.category-card {
    background-color: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--shadow-deep);
    
    border: 2px solid var(--primary-color); 
    
    display: flex;
    flex-direction: column;
    overflow: hidden;
    scroll-margin-top: 20px; 
}

/* Contêiner para o Título e o Botão de Excluir */
.category-title-container {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    padding: 15px 20px; 
    margin: 0;
}

.category-title-card {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    /* Cor do texto definida pelo JS para contraste */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2); 
    line-height: 1; 
}

/* NOVO/ATUALIZADO: Estilo do botão de exclusão do CARTÃO (Categoria) */
.delete-category-button {
    background-color: transparent;
    color: var(--main-text-color); 
    border: 2px solid var(--main-text-color);
    border-radius: 50%;
    width: 32px; /* Aumentado ligeiramente */
    height: 32px; /* Aumentado ligeiramente */
    line-height: 1;
    font-size: 1.4rem; /* Um pouco menor para caber melhor */
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 3px; 
    flex-shrink: 0; /* Impede o botão de encolher */
}

.delete-category-button:hover,
.delete-category-button:focus {
    background-color: #ff3333; /* Vermelho vivo */
    border-color: #ff3333;
    transform: scale(1.1);
    outline: none;
}


/* Contêiner interno para os links (com rolagem) */
.category-links-container {
    padding: 20px; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1; 
    
    max-height: 350px; 
    overflow-y: auto; 
    overflow-x: hidden;
    
    scrollbar-width: thin; 
    scrollbar-color: var(--primary-color) #f1f1f1; 
}

/* Webkit Scrollbar no Container de Links */
.category-links-container::-webkit-scrollbar {
    width: 6px;
}

.category-links-container::-webkit-scrollbar-thumb {
    background: var(--primary-color); 
    border-radius: 3px;
}

.category-links-container::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* --- ESTILO DO CARD DE LINK DENTRO DA CATEGORIA --- */
.app-card-item {
    display: flex;
    align-items: center;
    background-color: #f8f9fa; 
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    position: relative;
    border-left: 5px solid var(--category-link-color); 
}

.app-card-item:hover {
    background-color: #f1f3f5;
    transform: translateY(-2px);
}

.app-icon {
    width: 40px;
    height: 40px;
    margin-right: 15px;
    object-fit: contain;
    border-radius: 50%;
    border: 2px solid #ddd;
    padding: 2px;
}

.app-name {
    font-size: 1.1rem;
    font-weight: 600;
    flex-grow: 1;
    color: var(--text-color);
}

.delete-button {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background-color: red;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 1rem;
    line-height: 1;
    opacity: 0; 
    transition: opacity 0.2s;
}

.app-card-item:hover .delete-button {
    opacity: 1;
}

/* --- MEDIA QUERIES --- */
@media (max-width: 1024px) {
    .layout-container {
        flex-direction: column;
        padding: 0 15px;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        margin-right: 0;
        margin-bottom: 30px; 
        position: static; 
    }
    
    .sidebar-title {
        border-bottom: none;
    }

    .sidebar-nav-list {
        display: flex;
        flex-wrap: wrap; 
        gap: 8px;
        padding: 0 20px 10px 20px;
    }
    
    .sidebar-nav-item a {
        padding: 8px 12px;
        border-radius: 6px;
        border: 1px solid rgba(255, 255, 255, 0.4);
        border-left: none;
    }
    
    .sidebar-nav-item a:hover {
        border-left: none;
        background-color: var(--sidebar-link-hover);
    }
}

@media (max-width: 767px) {
    .hub-header {
        padding: 20px 15px 10px 15px;
    }
    
    .main-title {
        font-size: 3rem;
    }
    
    .categories-hub-grid {
        grid-template-columns: 1fr; 
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 2.5rem;
    }
    
    /* Ajuste para o botão do cartão em telas muito pequenas */
    .delete-category-button {
        width: 28px;
        height: 28px;
        font-size: 1.2rem;
    }
}
