:root {
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #4fc3dc;
    --text-color: #333;
    --bg-color: #f9f9f9;
    --card-bg: #fff;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --modal-bg: rgba(0, 0, 0, 0.5);
    --success-color: #28a745;
    --danger-color: #dc3545;
}

.dark-mode {
    --primary-color: #375a7f;
    --secondary-color: #2b4764;
    --accent-color: #3498db;
    --text-color: #f0f0f0;
    --bg-color: #222;
    --card-bg: #333;
    --border-color: #444;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --success-color: #48c774;
    --danger-color: #f14668;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px var(--shadow-color);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 10px;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.3s ease;
}

button:hover {
    opacity: 0.9;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

#dark-mode-toggle, #export-json, #import-json {
    background-color: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

main {
    padding: 2rem 0;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.add-link-section {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.links-section {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    padding: 1.5rem;
}

.links-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.links-filter {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.search-box input {
    padding-left: 30px;
}

.category-section {
    margin-bottom: 2rem;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.category-header i {
    color: var(--primary-color);
}

.category-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.link-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 
        "icon details actions";
    gap: 1rem;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.link-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--shadow-color);
}

.link-icon {
    grid-area: icon;
    font-size: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: rgba(74, 111, 165, 0.1);
    border-radius: 50%;
    flex-shrink: 0;
}

.link-details {
    grid-area: details;
    min-width: 0;
    overflow: hidden;
}

.link-actions {
    grid-area: actions;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.btn-edit, .btn-delete {
    background-color: transparent;
    color: #777;
    padding: 10px;
    font-size: 1.1rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

@media (max-width: 768px) {
    .link-card {
        grid-template-columns: auto 1fr auto;
        grid-template-areas: 
            "icon details actions";
    }
    
    .link-actions {
        flex-direction: column;
    }
}
.link-details h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-url {
    display: block;
    color: var(--accent-color);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.link-url:hover {
    text-decoration: underline;
}

.link-description {
    font-size: 0.9rem;
    color: #777;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 5px;
}

.btn-edit:hover {
    color: var(--accent-color);
    background-color: rgba(79, 195, 220, 0.1);
}

.btn-delete:hover {
    color: var(--danger-color);
    background-color: rgba(220, 53, 69, 0.1);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto; /* Reduzido de 10% para 5% para ficar mais alto na tela */
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh; /* Limitar altura máxima */
    overflow-y: auto; /* Adicionar rolagem vertical se necessário */
    box-shadow: 0 5px 15px var(--shadow-color);
    position: relative;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
}

.no-links {
    text-align: center;
    padding: 2rem;
    color: #777;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #777;
}

footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .add-link-section {
        position: static;
    }
    
    .links-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .links-filter {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-box, .links-filter select {
        width: 100%;
    }
    
    .category-links {
        grid-template-columns: 1fr;
    }
    
    .link-card {
        flex-direction: column;
    }
    
    .link-actions {
        flex-direction: row;
        width: 100%;
        justify-content: flex-end;
    }
}