/* CA Certificate Server - Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

/* Header */
header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

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

header h1 a {
    text-decoration: none;
    color: inherit;
}

header nav {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

header nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s;
}

header nav a:hover {
    color: var(--primary-color);
}

header nav a.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* User Info in Header */
header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .container > div:first-child {
    flex: 1;
}

header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

header .user-info .username {
    font-weight: 500;
    color: var(--text-color);
}

header .user-info .role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

header .user-info .role-admin {
    background: #dc3545;
    color: #fff;
}

header .user-info .role-user {
    background: #6c757d;
    color: #fff;
}

header .user-info .btn-logout,
header .user-info .btn-login {
    padding: 6px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

header .user-info .btn-logout {
    background: #dc3545;
    color: #fff;
}

header .user-info .btn-logout:hover {
    background: #c82333;
}

header .user-info .btn-login {
    background: var(--primary-color);
    color: #fff;
}

header .user-info .btn-login:hover {
    background: var(--primary-hover);
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding-bottom: 2rem;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.flash.success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

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

.flash.warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.flash.info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

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

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

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

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

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    margin-right: 0.5rem;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-revoke {
    color: var(--error-color);
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card.success {
    border-left: 4px solid var(--success-color);
}

.card.error {
    border-left: 4px solid var(--error-color);
}

.card.info {
    border-left: 4px solid var(--primary-color);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Tables */
.cert-table {
    width: 100%;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cert-table thead {
    background-color: #f1f5f9;
}

.cert-table th,
.cert-table td {
    padding: 0.75rem 1rem;
    text-align: left;
}

.cert-table th {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cert-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.cert-table tbody tr:last-child {
    border-bottom: none;
}

.cert-table tbody tr:hover {
    background-color: #f8fafc;
}

.cert-table tbody tr.revoked {
    opacity: 0.6;
    background-color: #fef2f2;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-valid {
    background-color: #dcfce7;
    color: #166534;
}

.badge-revoked {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Detail Tables */
.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table tr {
    border-bottom: 1px solid var(--border-color);
}

.detail-table th,
.detail-table td {
    padding: 0.75rem;
    text-align: left;
}

.detail-table th {
    width: 200px;
    font-weight: 500;
    color: var(--secondary-color);
}

.detail-table code {
    background-color: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    word-break: break-all;
}

/* Detail Actions */
.detail-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Warning Box */
.warning-box {
    background-color: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #92400e;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-state p {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

/* List Header */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.list-header p {
    color: var(--secondary-color);
}

.filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Help Section */
.help-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.help-section h3,
.help-section h4 {
    margin-bottom: 1rem;
}

.help-section pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-size: 0.875rem;
}

.help-section code {
    font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
}

.help-section ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.help-section li {
    margin-bottom: 0.5rem;
}

/* 搜索栏 */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

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

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 14px;
}

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

.pagination .current {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .ellipsis {
    border: none;
    padding: 8px;
}

.pagination .page-info {
    border: none;
    margin-left: 10px;
    color: var(--secondary-color);
}

/* 过期证书样式 */
.badge-expired {
    background: #fee2e2;
    color: #991b1b;
}

/* Footer */
footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--secondary-color);
    font-size: 0.875rem;
}

/* Home Page */
.home h2 {
    margin-bottom: 1.5rem;
}

.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.status-cards .card h3 {
    font-size: 0.875rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.status-cards .card p {
    font-size: 1.25rem;
    font-weight: 600;
}

.actions h3 {
    margin-bottom: 1rem;
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.info-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.info-section ol {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-section li {
    margin-bottom: 0.5rem;
}

.info-section pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-size: 0.875rem;
}

/* Detail Header */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.detail-header h3 {
    font-size: 1.5rem;
}

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

    .cert-table {
        font-size: 0.875rem;
    }

    .cert-table th,
    .cert-table td {
        padding: 0.5rem;
    }

    header nav {
        flex-direction: column;
        gap: 0.5rem;
    }
}