:root {
    --bg-color: #1a1a1a;
    --surface-color: #2c2c2c;
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --text-color: #f0f0f0;
    --text-muted: #a0a0a0;
    --border-color: #444;
    --success-color: #198754;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: var(--bg-color); color: var(--text-color); line-height: 1.6; }
.container { max-width: 1200px; margin: 20px auto; padding: 20px; }

/* ESTILOS DA TELA DE LOGIN */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 1rem; }
.login-form { background-color: var(--surface-color); padding: 2.5rem; border-radius: 8px; width: 100%; max-width: 400px; text-align: center; }
.login-form h2 { margin-bottom: 1.5rem; }
.login-form .input-group { text-align: left; margin-bottom: 1rem; }
.login-form label { display: block; margin-bottom: 0.5rem; color: var(--text-muted); }
.login-form button { background-color: var(--primary-color); width: 100%; margin-top: 1rem; }
.login-form button:hover { background-color: var(--primary-hover); }

/* ESTILOS DO PAINEL */
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; gap: 1rem; }
header h1 { font-size: 1.5rem; }
.logout-btn { background: var(--surface-color); color: var(--text-color); padding: 0.5rem 1rem; border-radius: 5px; text-decoration: none; border: 1px solid var(--border-color); transition: background-color 0.2s; white-space: nowrap; }
.logout-btn:hover { background-color: #333; }
.form-container, .search-container, .table-container { background-color: var(--surface-color); padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; }
#add-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
#add-form .form-row-last { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
#add-form .form-row-last button { background-color: var(--primary-color); }
#add-form .form-row-last button:hover { background-color: var(--primary-hover); }

input[type="text"], input[type="password"], input[type="url"] { width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 4px; background-color: var(--bg-color); color: var(--text-color); font-size: 1rem; }
button { padding: 0.75rem 1.5rem; border: none; border-radius: 4px; color: white; cursor: pointer; transition: background-color 0.2s; font-size: 1rem; }

/* FILTROS DE CATEGORIA */
.category-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; background-color: var(--surface-color); padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; }
.category-btn {
    color: white;
    border: 3px solid transparent;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-size: 0.9rem;
    font-weight: 500;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
    display: inline-block;
}
.category-btn:hover { transform: scale(1.05); opacity: 0.9; }
.category-btn.active { border-color: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.4); transform: scale(1.05); }
.category-btn[data-category="all"] { background-color: #4a4a4a; }
.category-btn[data-category="all"].active { border-color: var(--primary-color); }

#search { width: 100%; }
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.col-link-curto { width: 35%; }
.col-link-destino { width: 42%; }
.col-cliques { width: 8%; text-align: center; }
.col-acoes { width: 15%; text-align: center; }
td[data-label="Cliques"] { text-align: center; }
td a { color: #8cb4ff; text-decoration: none; }
td a:hover { text-decoration: underline; }
.truncate-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-buttons { display: flex; align-items: center; justify-content: center; gap: 0.75rem; }
.action-buttons form { margin: 0; }
.action-btn { background: none; color: var(--text-muted); padding: 0.5rem; font-size: 1rem; border-radius: 5px; width: 40px; height: 40px; line-height: 1; text-align: center; }
.action-btn:hover { color: var(--text-color); background-color: #444; }
.edit-container { display: none; }
.edit-container form { display: flex; align-items: center; gap: 5px; }
.edit-container button { background-color: var(--success-color); }
.message { padding: 1rem; margin-bottom: 1.5rem; border-radius: 5px; text-align: center; }
.message.success { background-color: #0f5132; color: #75b798; }
.message.error { background-color: #842029; color: #f5c2c7; }

/* LÓGICA DE EDIÇÃO SIMPLIFICADA */
.edit-btn .icon-cancel { display: none; }
.is-editing .link-display { display: none; }
.is-editing .edit-container { display: flex; }
.is-editing .edit-btn .icon-edit { display: none; }
.is-editing .edit-btn .icon-cancel { display: block; }
.is-editing .action-buttons .delete-form { display: none; }

/* MODO MOBILE */
@media (max-width: 768px) {
    #add-form .form-row, #add-form .form-row-last { grid-template-columns: 1fr; }
    .category-filters { padding: 1rem; }
    .table-container { overflow-x: hidden; background-color: transparent; padding: 0;}
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { background: var(--surface-color); padding: 15px; border-radius: 8px; margin-bottom: 1rem; }
    td { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
    td:last-child { border-bottom: none; }
    td:before { content: attr(data-label); font-weight: 600; color: var(--text-muted); padding-right: 10px; text-align: left;}
    .col-link-curto, .col-link-destino, .col-cliques, .col-acoes { width: auto; text-align: right; }
    td[data-label="Ações"] { justify-content: flex-end; }
    .truncate-cell { max-width: 60%; }
}
