/* Global Styles */
body {
    font-family: "SF Pro Text", "Myriad Set Pro", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    margin: 0;
    padding: 20px 0;
    /* Add top/bottom padding to body */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

h1,
h2,
h3 {
    font-weight: 600;
    margin-top: 0;
}

.header-title {
    text-align: center;
    margin-bottom: 40px;
    /* Keep the complete desktop title on one balanced line.  The former
       2.5em size exceeded the search panel's content width and could split
       the final word ("系统") character by character. */
    font-size: clamp(2rem, 4vw, 2.125rem);
    line-height: 1.25;
    white-space: nowrap;
    color: #1d1d1f;
}

.admin-login {
    color: #4e5564;
    font-size: 0.875em;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.admin-login:hover,
.admin-login:focus {
    color: #005bb5;
}

/* Card Style */
.card {
    background: #fff;
    border-radius: 12px;
    /* Slightly tighter radius */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* Softer, simpler shadow */
    padding: 24px;
    margin-bottom: 30px;
    /* More spacing */
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9em;
    color: #86868b;
}

input[type="text"],
input[type="password"],
input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    background-color: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus {
    border-color: #0071e3;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
    outline: none;
}

button {
    background-color: #0071e3;
    color: white;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #0077ed;
}

.btn-danger {
    background-color: #ff3b30;
}

.btn-danger:hover {
    background-color: #ff453a;
}

.btn-edit {
    background-color: #34c759;
}

.btn-edit:hover {
    background-color: #32d74b;
}

/* Tables */
/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

/* ... existing code ... */

/* Action Column - specific styling */
table th:last-child,
table td:last-child {
    text-align: center;
    vertical-align: middle;
    padding: 8px 4px;
    /* Reduced padding for compact look */
}

.action-header {
    text-align: center;
    white-space: nowrap;
    font-weight: bold;
}

/* Action Grid Container - The anchor for alignment */
.action-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    /* Align items to start grid */
    align-content: center;
    gap: 4px;

    /* Crucial: Set fixed width of the CONTAINER. 
       Table cell will auto-expand to fit this. 
       3 buttons (48px) + 2 gaps (4px) = 144 + 8 = 152px. 
       Safe width: 155px. */
    width: 155px;

    /* Center the container within the cell */
    margin: 0 auto;
}

/* Action Buttons */
.action-form {
    display: inline-flex;
    margin: 0;
}

.action-grid .btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 28px;
    padding: 0;
    margin: 0;
    font-size: 12px;
    border-radius: 4px;
    line-height: normal;
}

th,
td {
    padding: 18px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e5ea;
    font-size: 14px;
    vertical-align: middle;
}

th {
    font-weight: 600;
    color: #86868b;
    background-color: #fafafa;
    /* Light gray header */
    border-top: 1px solid #e5e5ea;
}

th:first-child {
    border-top-left-radius: 8px;
    border-left: 1px solid #e5e5ea;
}

th:last-child {
    border-top-right-radius: 8px;
    border-right: 1px solid #e5e5ea;
}

td:first-child {
    border-left: 1px solid #e5e5ea;
}

td:last-child {
    border-right: 1px solid #e5e5ea;
}

tr:hover {
    background-color: #fbfbfb;
}

/* Section Headers for Tables */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 2rem;
}

.text-danger {
    color: #ff3b30;
}

.text-warning {
    color: #ff9f0a;
}

.text-success {
    color: #34c759;
}

.alert {
    padding: 16px;
    background-color: #f2f2f7;
    border-radius: 12px;
    margin-bottom: 20px;
}

.alert-warning {
    background-color: #fff4e5;
    color: #663c00;
    border-left: 4px solid #ff9f0a;
}

/* Search Box Specifics */
.search-box {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.result-item {
    border-left: 4px solid #0071e3;
}

.result-item.expiring {
    border-left-color: #ff3b30;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5ea;
}

.logo {
    font-weight: 700;
    font-size: 1.4em;
    text-decoration: none;
    color: #1d1d1f;
}

.btn-action {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    color: white;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
    text-align: center;
    white-space: nowrap;
    width: 56px;
    margin: 2px;
}

.btn-action:hover {
    opacity: 0.85;
}

/* Action Column */


/* Adjust colors specifically if needed, but keeping existing inline styles in PHP or generic classes */
.btn-action:hover {
    opacity: 0.85;
}


/* Status Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Info Icon Button */
.btn-icon-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #0071e3;
    color: white;
    font-size: 0;
    /* Hide text if any, but SVG ignores this */
    line-height: 1;
    /* Center SVG */
    transition: opacity 0.2s;
    cursor: pointer;
    border: 0;
    padding: 0;
}

.btn-icon-info:hover {
    opacity: 0.8;
    background-color: #005bb5;
}

.badge-warning {
    background: #fff4e5;
    color: #ff9f0a;
}

.badge-danger {
    background: #ffe5e5;
    color: #ff3b30;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 15% auto;
    padding: 20px;
    border-radius: 12px;
    width: 300px;
    text-align: center;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 36px;
    height: 36px;
    line-height: 34px;
    /* Vertically center the x */
    font-size: 28px;
    cursor: pointer;
    color: #86868b;
    background: #f5f5f7;
    border-radius: 50%;
    /* Circle shape */
    text-align: center;
    font-weight: bold;
    transition: all 0.2s ease;
    z-index: 1001;
    /* Ensure on top */
}

.close-btn:hover {
    color: #1d1d1f;
    background: #e5e5ea;
    transform: scale(1.1);
}

.history-list {
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
    line-height: 2;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding-top: 58px;
    }

    .platform-home {
        position: absolute;
    }

    .container {
        padding: 0 15px;
        margin-top: 20px;
    }

    .header-title {
        font-size: 1.8em;
        margin-bottom: 20px;
        white-space: normal;
    }

    /* Force table to not be like tables anymore */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin: 0 0 15px 0;
        background: #fff;
        border: 1px solid #e5e5ea;
        border-radius: 12px;
        padding: 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    tr:nth-child(odd) {
        background: #fff;
        /* Reset zebra striping */
    }

    td {
        /* Behave  like a "row" */
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 0;
        text-align: left;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        /* Now like a table header */
        position: relative;
        /* Top/left values mimic padding */
        top: 0;
        left: 0;
        width: 100%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: #86868b;
        display: block;
        font-size: 0.85em;
        margin-bottom: 4px;
        content: attr(data-label);
    }

    .navbar {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    /* Adjust button sizes for touch */
    .btn-action {
        padding: 8px 12px;
        font-size: 14px;
        margin-bottom: 5px;
        display: inline-block;
    }

    /* Adjust inputs */
    input[type="text"],
    input[type="date"],
    textarea {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }
}

/* Popup Form Enhancements */
.popup-form-card {
    padding: 40px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    border-radius: 16px !important;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.popup-form-card h3 {
    margin-bottom: 30px;
    font-size: 24px;
    text-align: center;
    color: #1d1d1f;
}

.popup-form-card .form-group {
    margin-bottom: 25px;
}

.platform-home {
    position: fixed;
    top: 16px;
    left: 18px;
    z-index: 100;
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: #515154;
    text-decoration: none;
    font-size: 13px;
}

.platform-home:hover {
    color: #0071e3;
    border-color: #0071e3;
}
