/* =========================================================
   WSaiOS-ICAI Learning System
   Admin UI
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Microsoft YaHei",
        "PingFang SC",
        Arial,
        sans-serif;

    background: #f4f6f9;
    color: #263238;
    font-size: 14px;
    line-height: 1.6;
}


/* =========================================================
   Topbar
   ========================================================= */

.topbar {
    height: 68px;
    display: flex;
    align-items: center;

    padding: 0 32px;

    background: #1f2937;
    color: #ffffff;

    border-bottom: 1px solid #111827;
}

.brand {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.subtitle {
    margin-left: 22px;

    font-size: 13px;
    color: #cbd5e1;
}


/* =========================================================
   Navigation
   ========================================================= */

.nav {
    display: flex;
    align-items: center;

    min-height: 52px;
    padding: 0 32px;

    background: #ffffff;

    border-bottom: 1px solid #e5e7eb;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.nav a {
    display: inline-flex;
    align-items: center;

    height: 52px;

    padding: 0 18px;

    color: #4b5563;
    text-decoration: none;

    font-size: 14px;

    border-bottom: 2px solid transparent;

    transition:
        color 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease;
}

.nav a:hover {
    color: #2563eb;
    background: #f8fafc;
}

.nav a:active {
    background: #f1f5f9;
}


/* =========================================================
   Main Container
   ========================================================= */

.container {
    width: calc(100% - 64px);
    max-width: 1400px;

    margin: 0 auto;

    padding: 30px 0 50px;
}

.container > h1 {
    margin: 0 0 24px;

    font-size: 26px;
    line-height: 1.3;

    font-weight: 600;

    color: #111827;
}


/* =========================================================
   Panel
   ========================================================= */

.panel {
    margin-bottom: 24px;
    padding: 24px;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 10px;

    box-shadow:
        0 2px 6px rgba(15, 23, 42, 0.04);
}

.panel h2 {
    margin: 0 0 22px;

    font-size: 17px;
    font-weight: 600;

    color: #1f2937;
}


/* =========================================================
   Message
   ========================================================= */

.message {
    margin-bottom: 20px;
    padding: 12px 15px;

    background: #eff6ff;

    border: 1px solid #bfdbfe;
    border-radius: 7px;

    color: #1d4ed8;

    font-size: 14px;
}


/* =========================================================
   Form
   ========================================================= */

form {
    margin: 0;
}

label {
    display: block;

    margin: 0 0 7px;

    color: #374151;

    font-size: 13px;
    font-weight: 600;
}

select,
input[type="text"],
input[type="url"],
input[type="file"] {
    width: 100%;

    min-height: 40px;

    padding: 8px 11px;

    background: #ffffff;

    border: 1px solid #d1d5db;
    border-radius: 6px;

    color: #374151;

    font-family: inherit;
    font-size: 14px;

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

select {
    cursor: pointer;
}

input[type="file"] {
    padding: 7px 10px;
}

select:focus,
input[type="text"]:focus,
input[type="url"]:focus,
input[type="file"]:focus {
    border-color: #60a5fa;

    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.10);
}

input::placeholder {
    color: #9ca3af;
}


/* =========================================================
   Source Input Sections
   ========================================================= */

#url_source,
#file_source,
#open_information_source {
    margin-top: 18px;
}


/* =========================================================
   Buttons
   ========================================================= */

button {
    min-height: 38px;

    padding: 8px 16px;

    border: 1px solid #2563eb;
    border-radius: 6px;

    background: #2563eb;
    color: #ffffff;

    font-family: inherit;
    font-size: 13px;
    font-weight: 500;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.05s ease;
}

button:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;

    box-shadow:
        0 2px 5px rgba(37, 99, 235, 0.18);
}

button:active {
    transform: translateY(1px);
}

button:focus {
    outline: none;

    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.12);
}


/* =========================================================
   Main Save Button
   ========================================================= */

.panel > form > button[type="submit"] {
    margin-top: 20px;

    min-width: 160px;
}


/* =========================================================
   Table
   ========================================================= */

table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;

    overflow: hidden;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 8px;

    font-size: 13px;
}

thead th {
    padding: 13px 14px;

    background: #f8fafc;

    color: #374151;

    font-size: 13px;
    font-weight: 600;

    text-align: left;

    border-bottom: 1px solid #e5e7eb;

    white-space: nowrap;
}

tbody td {
    padding: 13px 14px;

    color: #4b5563;

    vertical-align: middle;

    border-bottom: 1px solid #f0f2f5;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #fafcff;
}


/* =========================================================
   Table Source Column
   ========================================================= */

tbody td:nth-child(3) {
    max-width: 430px;

    word-break: break-all;
}


/* =========================================================
   Status
   ========================================================= */

tbody td:nth-child(4) {
    color: #15803d;
    font-weight: 500;
}


/* =========================================================
   Action Area
   ========================================================= */

tbody td:last-child {
    min-width: 260px;

    white-space: nowrap;
}

tbody td:last-child a {
    color: #2563eb;

    text-decoration: none;

    font-weight: 500;
}

tbody td:last-child a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}


/* =========================================================
   Delete Button
   ========================================================= */

tbody td:last-child form {
    display: inline;
}

tbody td:last-child form button {
    min-height: 32px;

    padding: 5px 11px;

    background: #ffffff;
    color: #dc2626;

    border-color: #fecaca;

    font-size: 12px;
}

tbody td:last-child form button:hover {
    background: #fef2f2;
    color: #b91c1c;

    border-color: #fca5a5;

    box-shadow: none;
}


/* =========================================================
   Replace Button
   ========================================================= */

tbody td:last-child > button {
    min-height: 32px;

    padding: 5px 11px;

    background: #ffffff;
    color: #2563eb;

    border-color: #bfdbfe;

    font-size: 12px;
}

tbody td:last-child > button:hover {
    background: #eff6ff;

    border-color: #93c5fd;

    box-shadow: none;
}


/* =========================================================
   Replace Form
   ========================================================= */

[id^="replace_"] {
    padding: 12px;

    background: #f8fafc;

    border: 1px solid #e5e7eb;
    border-radius: 7px;
}

[id^="replace_"] form {
    display: flex;
    align-items: center;

    gap: 8px;

    flex-wrap: wrap;
}

[id^="replace_"] input[type="text"] {
    width: 300px;

    min-height: 34px;
}

[id^="replace_"] input[type="file"] {
    width: auto;

    min-width: 250px;

    min-height: 34px;
}

[id^="replace_"] form button {
    min-height: 34px;

    padding: 6px 13px;

    font-size: 12px;
}


/* =========================================================
   Footer
   ========================================================= */

.footer {
    padding: 24px 20px 30px;

    text-align: center;

    color: #9ca3af;

    font-size: 12px;
}


/* =========================================================
   Empty Table
   ========================================================= */

tbody:empty::after {
    content: "";
}


/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1000px) {

    .topbar {
        padding: 0 20px;
    }

    .nav {
        padding: 0 20px;

        overflow-x: auto;
    }

    .nav a {
        flex-shrink: 0;

        padding: 0 13px;
    }

    .container {
        width: calc(100% - 40px);
    }

    .panel {
        padding: 20px;
    }

    table {
        display: block;

        overflow-x: auto;
    }

}


@media (max-width: 700px) {

    .topbar {
        height: auto;

        padding: 15px 18px;

        display: block;
    }

    .brand {
        font-size: 17px;
    }

    .subtitle {
        margin: 4px 0 0;
    }

    .nav {
        padding: 0 10px;
    }

    .container {
        width: calc(100% - 24px);

        padding-top: 20px;
    }

    .container > h1 {
        font-size: 22px;
    }

    .panel {
        padding: 16px;
    }

    [id^="replace_"] form {
        display: block;
    }

    [id^="replace_"] input[type="text"],
    [id^="replace_"] input[type="file"] {
        width: 100%;

        margin-bottom: 8px;
    }

}


/* =========================================================
   Information Source Actions
   ========================================================= */

.source-actions {
    display: inline-flex;

    align-items: center;

    gap: 7px;

    white-space: nowrap;
}

.source-actions a,
.source-actions button {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    min-width: 52px;
    height: 32px;

    padding: 0 11px;

    border-radius: 5px;

    font-family: inherit;
    font-size: 12px;
    font-weight: 500;

    text-decoration: none;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}


/* 查看 */

.source-actions .action-view {
    background: #eff6ff;

    border: 1px solid #bfdbfe;

    color: #2563eb;
}

.source-actions .action-view:hover {
    background: #dbeafe;

    border-color: #93c5fd;

    color: #1d4ed8;

    text-decoration: none;
}


/* 替换 */

.source-actions .action-replace {
    background: #f8fafc;

    border: 1px solid #d1d5db;

    color: #4b5563;
}

.source-actions .action-replace:hover {
    background: #f1f5f9;

    border-color: #9ca3af;

    color: #1f2937;

    box-shadow: none;
}


/* 删除 */

.source-actions .action-delete {
    background: #ffffff;

    border: 1px solid #fecaca;

    color: #dc2626;
}

.source-actions .action-delete:hover {
    background: #fef2f2;

    border-color: #fca5a5;

    color: #b91c1c;

    box-shadow: none;
}


/* 删除表单取消默认间距 */

.source-actions .action-delete-form {
    display: inline-flex;

    margin: 0;
}


/* =========================================================
   Dashboard Grid
   ========================================================= */

.grid {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 20px;

    margin-bottom: 24px;
}


/* =========================================================
   Dashboard Card
   ========================================================= */

.card {
    min-width: 0;

    padding: 22px 24px;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 10px;

    box-shadow:
        0 2px 6px rgba(15, 23, 42, 0.04);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.card:hover {
    border-color: #d1d5db;

    box-shadow:
        0 4px 12px rgba(15, 23, 42, 0.08);

    transform: translateY(-1px);
}


.card h3 {
    margin: 0 0 12px;

    color: #1f2937;

    font-size: 17px;
    line-height: 1.4;

    font-weight: 600;
}


.card p {
    min-height: 45px;

    margin: 0 0 18px;

    color: #6b7280;

    font-size: 14px;
    line-height: 1.6;
}


.card a {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    min-width: 72px;
    height: 34px;

    padding: 0 14px;

    background: #eff6ff;

    border: 1px solid #bfdbfe;
    border-radius: 6px;

    color: #2563eb;

    font-size: 13px;
    font-weight: 500;

    text-decoration: none;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}


.card a:hover {
    background: #dbeafe;

    border-color: #93c5fd;

    color: #1d4ed8;

    text-decoration: none;
}


/* =========================================================
   Dashboard Grid Responsive
   ========================================================= */

@media (max-width: 1000px) {

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 700px) {

    .grid {
        grid-template-columns: 1fr;

        gap: 16px;
    }

    .card {
        padding: 20px;
    }

}