/* ========================================
   短地址系统 - 样式表
   ======================================== */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* ---------- Header ---------- */
.header {
    text-align: center;
    margin-bottom: 32px;
    color: #fff;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.85;
}

/* ---------- Card ---------- */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    color: #555;
}

/* ---------- Form ---------- */
.url-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.form-group input[type="url"],
.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-group input::placeholder {
    color: #bdbdbd;
}

.form-hint {
    font-size: 0.8rem;
    color: #999;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.form-row .flex-1 {
    flex: 1;
}

.form-action {
    flex-shrink: 0;
    justify-content: flex-end;
    padding-bottom: 0;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-copy {
    background: #f0f0f0;
    color: #555;
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 6px;
}

.btn-copy:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-danger:disabled,
.btn-danger.disabled {
    background: #f5b7b1;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid #d0d0d0;
    color: #555;
}

.btn-outline:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-secondary {
    background: #f0f0f0;
    color: #555;
}

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

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 16px;
}

.alert-error {
    background: #fff5f5;
    color: #c0392b;
    border: 1px solid #f5b7b1;
}

.alert-success {
    background: #f0fff4;
    color: #27ae60;
    border: 1px solid #a3e4bc;
}

/* ---------- Result Box ---------- */
.result-box {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #f0f4ff, #faf0ff);
    border-radius: 10px;
    border: 1px solid #d4d9f5;
}

.result-icon {
    width: 40px;
    height: 40px;
    background: #27ae60;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    flex-shrink: 0;
}

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

.result-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.result-url-row {
    display: flex;
    gap: 10px;
}

.result-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    color: #333;
    outline: none;
}

.result-code {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
}

.copy-msg {
    font-size: 0.85rem;
    color: #27ae60;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.3s;
}

.copy-msg.show {
    opacity: 1;
}

/* ---------- Info Card ---------- */
.info-card ul {
    padding-left: 20px;
    font-size: 0.9rem;
    color: #666;
    line-height: 2;
}

.info-card code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: #667eea;
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    padding: 20px 0;
}

.footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.footer a:hover {
    color: #fff;
}

/* ========================================
   Admin Styles
   ======================================== */

.admin-body {
    background: #f5f6fa;
}

.admin-header {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 0 20px;
}

.admin-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
}

.admin-header h1 {
    font-size: 1.3rem;
    color: #333;
}

.admin-header h1 a {
    color: #333;
    text-decoration: none;
}

.admin-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-nav {
    display: flex;
    gap: 4px;
}

.admin-nav a {
    padding: 8px 16px;
    border-radius: 6px;
    color: #555;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.admin-nav a:hover {
    background: #f0f0f0;
}

.admin-nav a.active {
    background: #667eea;
    color: #fff;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

.admin-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #333;
    font-size: 1.4rem;
}

.login-card .form-group {
    margin-bottom: 16px;
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 8px;
}

.login-back {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
}

.login-back a {
    color: #667eea;
    text-decoration: none;
}

.login-back a:hover {
    text-decoration: underline;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar select,
.toolbar input[type="text"] {
    padding: 8px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.toolbar select:focus,
.toolbar input:focus {
    border-color: #667eea;
}

.toolbar input[type="text"] {
    min-width: 200px;
}

.batch-actions {
    display: none;
    gap: 8px;
    align-items: center;
}

.batch-actions.show {
    display: flex;
}

.batch-count {
    font-size: 0.85rem;
    color: #666;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-card {
    flex: 1;
    min-width: 120px;
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #667eea;
}

.stat-label {
    font-size: 0.8rem;
    color: #999;
    margin-top: 4px;
}

/* Table */
.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 12px 14px;
    background: #f9fafb;
    border-bottom: 2px solid #e8e8e8;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.admin-table th.sort-asc::after {
    content: " ↑";
}

.admin-table th.sort-desc::after {
    content: " ↓";
}

.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

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

.admin-table .col-checkbox {
    width: 40px;
    text-align: center;
}

.admin-table .col-id {
    width: 60px;
}

.admin-table .col-code {
    width: 120px;
}

.admin-table .col-visits {
    width: 80px;
}

.admin-table .col-time {
    width: 140px;
}

.admin-table .col-actions {
    width: 130px;
}

.url-truncate {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.url-truncate a {
    color: #667eea;
    text-decoration: none;
}

.url-truncate a:hover {
    text-decoration: underline;
}

.short-code-tag {
    display: inline-block;
    background: #f0f4ff;
    color: #667eea;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.visit-count {
    font-weight: 600;
    color: #333;
}

.text-muted {
    color: #aaa;
    font-style: italic;
}

/* Action buttons in table */
.action-btns {
    display: flex;
    gap: 6px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #555;
    text-decoration: none;
    transition: all 0.2s;
}

.pagination a:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.pagination .active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    font-weight: 600;
}

.pagination .disabled {
    color: #ccc;
    pointer-events: none;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transform: translateX(calc(100% + 30px));
    transition: transform 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: #27ae60;
}

.toast-error {
    background: #e74c3c;
}

/* Modal / Confirm Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-box h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #333;
}

.modal-box p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 20px 14px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .card {
        padding: 20px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-action {
        width: 100%;
    }

    .form-action .btn {
        width: 100%;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        flex-wrap: wrap;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px 6px;
        font-size: 0.8rem;
    }

    .url-truncate {
        max-width: 150px;
    }

    .stats-bar {
        flex-direction: column;
    }
}
