/* Gestionnaire de liens - Style classique */
/* Compatible avec la structure index.php existante */

:root {
    --primary: #2c6e9b;
    --primary-dark: #205577;
    --secondary: #6c757d;
    --success: #2f855a;
    --danger: #c53030;
    --warning: #b7791f;
    --dark: #263238;
    --text: #374151;
    --muted: #6b7280;
    --background: #f4f6f8;
    --surface: #ffffff;
    --border: #d7dde3;
    --radius: 5px;
    --shadow: 0 2px 7px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--text);
    background: var(--background);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

button {
    cursor: pointer;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 18px;
}

/* En-tete */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 -18px 24px;
    padding: 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

header h1 {
    margin: 0;
    color: var(--dark);
    font-size: 24px;
    font-weight: normal;
    line-height: 1.25;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

nav a {
    display: inline-block;
    padding: 7px 10px;
    color: var(--text);
    border-radius: 4px;
}

nav a:hover {
    background: #eef2f5;
    text-decoration: none;
}

/* Barre de recherche */
.search-section {
    margin-bottom: 22px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 8px 11px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid #bfc7cf;
    border-radius: 4px;
    outline: none;
}

.search-input:focus,
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(44, 110, 155, 0.15);
}

.categories-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-tag {
    display: inline-block;
    padding: 5px 9px;
    color: #4b5563;
    background: #f8fafb;
    border: 1px solid var(--border);
    border-left: 4px solid var(--secondary);
    border-radius: 4px;
    font-size: 13px;
}

.category-tag:hover,
.category-tag.active {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
    text-decoration: none;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-weight: bold;
    line-height: 1.2;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    color: #ffffff;
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    color: #374151;
    background: #eef1f3;
    border-color: #d3d9df;
}

.btn-secondary:hover {
    color: #263238;
    background: #e1e6ea;
}

.btn-success {
    color: #ffffff;
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    color: #ffffff;
    background: #276749;
}

.btn-danger {
    color: #ffffff;
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    color: #ffffff;
    background: #9b2c2c;
}

.btn-small {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
}

/* Grille des liens */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.link-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.link-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.11);
}

.link-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.link-title {
    min-width: 0;
    margin: 0;
    font-size: 17px;
    font-weight: bold;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.link-title a {
    color: var(--dark);
}

.link-title a:hover {
    color: var(--primary);
}

.category-badge {
    flex: 0 0 auto;
    max-width: 45%;
    padding: 3px 6px;
    color: #ffffff;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-description {
    flex: 1 1 auto;
    margin: 0 0 12px;
    color: var(--muted);
}

.link-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 13px;
}

.tag {
    display: inline-block;
    padding: 3px 6px;
    color: #56616d;
    background: #edf0f2;
    border-radius: 3px;
    font-size: 11px;
}

.link-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 11px;
    border-top: 1px solid #edf0f2;
}

.link-date {
    color: #8b96a1;
    font-size: 11px;
}

.no-results {
    padding: 28px 18px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.no-results p {
    margin: 0;
}

/* Administration et formulaires */
.page-title {
    margin: 0 0 18px;
    color: var(--dark);
    font-size: 23px;
    font-weight: normal;
}

.admin-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.panel {
    margin-bottom: 18px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel h2,
.panel h3 {
    margin: 0 0 14px;
    color: var(--dark);
    font-size: 18px;
    font-weight: normal;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--dark);
    font-weight: bold;
}

.form-control {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 7px 9px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid #bfc7cf;
    border-radius: 4px;
    outline: none;
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 15px;
}

.alert {
    margin-bottom: 15px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.alert-success {
    color: #22543d;
    background: #f0fff4;
    border-color: #b7ebc6;
}

.alert-danger {
    color: #822727;
    background: #fff5f5;
    border-color: #f2b8b8;
}

.alert-warning {
    color: #744210;
    background: #fffaf0;
    border-color: #f6d89a;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 9px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--dark);
    background: #f1f4f6;
    font-size: 12px;
    white-space: nowrap;
}

td {
    font-size: 13px;
}

td a.url {
    display: block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* Connexion */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 390px;
    padding: 25px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-box h1 {
    margin: 0 0 20px;
    color: var(--dark);
    font-size: 23px;
    font-weight: normal;
    text-align: center;
}

/* Pied de page */
footer {
    margin: 30px 0 18px;
    color: #8b96a1;
    font-size: 12px;
    text-align: center;
}

footer p {
    margin: 0;
}

/* Responsive */
@media (max-width: 800px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 10px;
    }

    header {
        display: block;
        margin-right: -10px;
        margin-left: -10px;
        padding: 15px 10px;
    }

    header h1 {
        margin-bottom: 10px;
        font-size: 21px;
    }

    .search-section,
    .panel {
        padding: 13px;
    }

    .search-form {
        display: block;
    }

    .search-input {
        display: block;
        width: 100%;
        margin-bottom: 7px;
    }

    .search-form .btn {
        margin: 0 4px 4px 0;
    }

    .links-grid {
        grid-template-columns: 1fr;
    }

    .link-header {
        display: block;
    }

    .category-badge {
        display: inline-block;
        max-width: 100%;
        margin-top: 6px;
    }

    .link-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media print {
    header,
    nav,
    .search-section,
    .btn,
    .actions,
    footer {
        display: none !important;
    }

    html,
    body {
        background: #ffffff;
    }

    .link-card,
    .panel {
        box-shadow: none;
        break-inside: avoid;
    }
}

/* Interface admin moderne et lisible */
.admin-page {
    background: #f3f5f8;
    color: #263238;
}

.admin-header {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid #dfe5eb;
}

.admin-header h1 {
    margin-bottom: 3px;
    color: #243447;
    font-size: 25px;
    font-weight: 600;
}

.admin-subtitle {
    margin: 0;
    color: #8793a0;
    font-size: 13px;
}

.admin-content {
    min-height: 400px;
}

.admin-tabs {
    display: flex;
    gap: 3px;
    margin-bottom: 18px;
    padding: 5px;
    background: #e7ebf0;
    border-radius: 7px;
}

.admin-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 16px;
    color: #647180;
    background: transparent;
    border: 0;
    border-radius: 5px;
    font-weight: bold;
}

.admin-tab:hover {
    color: #263238;
    background: #f4f6f8;
}

.admin-tab.active {
    color: #245b82;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(32, 50, 70, 0.12);
}

.tab-icon {
    font-size: 16px;
}

.tab-count {
    min-width: 20px;
    padding: 2px 6px;
    color: #617184;
    background: #edf1f5;
    border-radius: 12px;
    font-size: 11px;
    text-align: center;
}

.admin-tab.active .tab-count {
    color: #245b82;
    background: #e4eff8;
}

.tab-panel {
    display: none;
    padding: 22px;
    background: #ffffff;
    border: 1px solid #dfe5eb;
    border-radius: 7px;
    box-shadow: 0 2px 8px rgba(36, 52, 71, 0.05);
}

.tab-panel.is-active {
    display: block;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #edf0f3;
}

.panel-heading h2 {
    margin: 0 0 4px;
    color: #243447;
    font-size: 20px;
    font-weight: 600;
}

.panel-heading p {
    margin: 0;
    color: #8793a0;
    font-size: 13px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 13px;
    margin-bottom: 22px;
}

.stat-card {
    position: relative;
    min-height: 125px;
    padding: 17px;
    overflow: hidden;
    border-radius: 6px;
}

.stat-card:after {
    position: absolute;
    right: -17px;
    bottom: -25px;
    width: 90px;
    height: 90px;
    border: 16px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    content: '';
}

.stat-blue {
    color: #24577d;
    background: #e5f0f8;
}

.stat-green {
    color: #286044;
    background: #e4f2eb;
}

.stat-orange {
    color: #815b21;
    background: #faf0dd;
}

.stat-icon {
    display: block;
    margin-bottom: 6px;
    font-size: 20px;
}

.stat-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
}

.stat-card strong {
    display: block;
    font-size: 22px;
    font-weight: 600;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    color: #334155;
    background: #fafbfc;
    border: 1px solid #e0e6eb;
    border-radius: 6px;
}

.quick-action:hover {
    color: #245b82;
    background: #f1f6fa;
    border-color: #bdd0df;
    text-decoration: none;
}

.quick-action > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: #ffffff;
    background: #5285a8;
    border-radius: 50%;
    font-size: 20px;
    font-weight: normal;
}

.quick-action strong,
.quick-action small {
    display: block;
}

.quick-action strong {
    margin-bottom: 2px;
    font-size: 14px;
}

.quick-action small {
    color: #8793a0;
    font-size: 12px;
}

.admin-form {
    padding: 17px;
    background: #fafbfc;
    border: 1px solid #e1e6eb;
    border-radius: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px 16px;
}

.form-wide {
    grid-column: 1 / -1;
}

.optional {
    color: #98a2ad;
    font-size: 11px;
    font-weight: normal;
}

.color-input-group {
    display: flex;
    gap: 7px;
}

.color-picker {
    flex: 0 0 42px;
    width: 42px;
    height: 38px;
    padding: 3px;
    background: #ffffff;
    border: 1px solid #c7d0d8;
    border-radius: 4px;
}

.color-input-group .form-control {
    flex: 1 1 auto;
}

.subsection-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 24px 0 10px;
}

.subsection-heading h3 {
    margin: 0;
    color: #334155;
    font-size: 16px;
    font-weight: 600;
}

.subsection-heading > span {
    color: #8b96a1;
    font-size: 12px;
}

.admin-table {
    border: 1px solid #e0e6eb;
    border-radius: 5px;
    overflow: hidden;
}

.admin-table th {
    color: #596879;
    background: #f3f6f8;
    border-bottom-color: #dce3e8;
}

.admin-table td {
    background: #ffffff;
}

.admin-table tbody tr:hover td {
    background: #fbfcfd;
}

.cell-title {
    color: #334155;
    font-weight: 600;
}

.table-category {
    display: inline-block;
    padding: 3px 7px;
    color: #45647d;
    background: #edf3f7;
    border-radius: 3px;
    font-size: 11px;
}

.muted {
    color: #9aa4af;
    font-size: 12px;
}

.category-list {
    border: 1px solid #e0e6eb;
    border-radius: 5px;
    overflow: hidden;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 13px;
    border-bottom: 1px solid #e9edf0;
}

.category-item:last-child {
    border-bottom: 0;
}

.category-item:hover {
    background: #fbfcfd;
}

.category-color {
    flex: 0 0 13px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.category-info {
    flex: 1 1 auto;
    min-width: 0;
}

.category-info strong,
.category-info small {
    display: block;
}

.category-info strong {
    color: #334155;
}

.category-info small {
    margin-top: 2px;
    color: #8a96a2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-page footer {
    color: #98a2ad;
}

@media (max-width: 760px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-wide {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .admin-tabs {
        display: grid;
        grid-template-columns: 1fr;
    }

    .admin-tab {
        justify-content: flex-start;
    }

    .tab-panel {
        padding: 14px;
    }

    .panel-heading {
        display: block;
    }

    .panel-heading .btn {
        margin-top: 12px;
    }

    .category-item {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .category-item .actions {
        width: 100%;
        margin-left: 24px;
    }
}
