/* css/toolbox.css */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --font-main: 'Plus Jakarta Sans', sans-serif;
    
    /* Light Mode Default */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --accent: #6366f1;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    /* Loại bỏ transition background ở body để tránh nháy toàn trang */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- SEARCH BAR --- */
.search-wrapper {
    display: flex;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box i { color: var(--text-muted); margin-right: 10px; }

.search-input {
    border: none;
    background: transparent;
    color: var(--text-main);
    width: 100%;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
}

.loading-spinner {
    width: 20px; height: 20px; 
    border: 2px solid var(--border-color); 
    border-top-color: var(--accent); 
    border-radius: 50%; 
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.filter-box {
    width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    color: var(--text-main);
    box-shadow: var(--shadow-card);
}

/* --- TOOL GRID --- */
.tool-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    height: 100%;
    
    /* CHỈ Transition các thuộc tính cần thiết */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
}

/* Link phủ toàn bộ card */
.tc-link-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1; /* Nằm trên nội dung thường */
}

.tc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.tc-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-body);
    font-size: 1.5rem;
    color: var(--accent);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.tc-icon img {
    width: 100%; height: 100%; object-fit: cover;
}

.tc-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.tc-badge.vis-private { color: #94a3b8; border-color: #94a3b8; }
.tc-badge.vis-custom { color: #f59e0b; border-color: #f59e0b; }

.tc-body h3 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    color: var(--text-main);
    line-height: 1.3;
}

.tc-body p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
    /* Cắt chữ 3 dòng */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.tc-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.tc-author img, .def-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    object-fit: cover;
}
.def-avatar {
    background: var(--border-color);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.tc-actions {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 2; /* Nằm trên overlay link để click được */
}

.btn-vote {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex; align-items: center; gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.btn-vote:hover {
    background: var(--bg-body);
    color: var(--accent);
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px dashed var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    .search-wrapper { flex-direction: column; gap: 10px; }
    .filter-box { width: 100%; }
    .tool-list { grid-template-columns: 1fr; }
}