/* Reset et variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --max-width: 1200px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.3s;
}

nav a:hover {
    background: var(--background);
}

/* Boutons */
.btn-primary, .btn-secondary {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1rem;
    flex: 1;
}

/* Barre de recherche */
.search-bar {
    margin-bottom: 2rem;
}

.search-bar form {
    display: flex;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-bar button {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.search-bar button:hover {
    background: var(--primary-hover);
}

/* Grille de liens */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Carte de lien */
.link-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.link-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.link-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--background);
}

.link-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.link-content h2,
.link-content h3 {
    color: var(--text-color);
    font-size: 1.25rem;
    line-height: 1.4;
}

.link-description {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.link-description strong {
    color: var(--text-color);
    font-weight: 600;
}

.link-description em {
    font-style: italic;
}

.link-description a {
    color: var(--primary-color);
    text-decoration: none;
}

.link-description a:hover {
    text-decoration: underline;
}

/* Tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--background);
    color: var(--primary-color);
    border-radius: 999px;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.3s;
    border: 1px solid var(--border-color);
}

.tag:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* URL du lien */
.link-url {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    text-align: center;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.link-url:hover {
    background: var(--primary-hover);
}

.link-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 2rem 0;
}

.pagination a {
    padding: 0.5rem 1rem;
    background: var(--card-background);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
}

.pagination span {
    color: var(--text-muted);
}

/* Formulaires */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    background: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.form-container h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form button[type="submit"] {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

/* Messages */
.success, .error {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.hint {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* État vide */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    color: var(--text-color);
}

/* Cloud de tags */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 2rem 0;
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.tag-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.tag-name {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 1.1rem;
}

.tag-count {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Actions sur les liens */
.link-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-edit,
.btn-delete-link {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-edit {
    background: #3b82f6;
    color: white;
}

.btn-edit:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-delete-link {
    background: #ef4444;
    color: white;
}

.btn-delete-link:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Page de suppression */
.delete-confirmation {
    max-width: 700px;
}

.link-preview-delete {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
    border: 2px solid var(--border-color);
}

.link-preview-delete img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.link-preview-delete h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.link-preview-delete .link-url {
    color: var(--primary-color);
    word-break: break-all;
    margin-bottom: 1rem;
    display: block;
}

.link-preview-delete .link-description {
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--border-radius);
}

.link-preview-delete .link-date {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.delete-question {
    text-align: center;
    font-size: 1.125rem;
    color: var(--text-color);
    margin: 1.5rem 0;
    font-weight: 500;
}

.delete-form {
    margin-top: 2rem;
}

.btn-delete {
    background: #ef4444 !important;
    color: white;
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-decoration: none;
}

.btn-delete:hover {
    background: #dc2626 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-cancel {
    background: var(--background);
    color: var(--text-color);
    padding: 0.875rem 2rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-decoration: none;
}

.btn-cancel:hover {
    border-color: var(--text-color);
    transform: translateY(-2px);
}

.alert-warning {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.alert-success {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

/* Image preview dans le formulaire */
.image-preview {
    margin-top: 1rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.image-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
}

/* Bouton retour dans le header du formulaire */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.btn-back {
    background: var(--background);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.3s;
}

.btn-back:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(-2px);
}

/* Actions du formulaire */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
}

.btn-submit {
    background: var(--primary-color);
    color: white;
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-submit:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Responsive */
@media (max-width: 768px) {
    .link-actions {
        flex-direction: column;
    }
    
    .btn-edit,
    .btn-delete-link {
        text-align: center;
        justify-content: center;
    }
    
    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button,
    .form-actions a {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .delete-form .form-actions {
        flex-direction: column-reverse;
    }
}

/* Footer */
footer {
    background: var(--card-background);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

footer .container {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    nav {
        justify-content: center;
    }
    
    .links-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .search-bar form {
        flex-direction: column;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tags-cloud {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    nav a {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .form-container {
        padding: 1.5rem;
    }
}
