:root {
    --primary-color: #4338ca;
    --primary-hover: #3730a3;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border-color: #d1d5db;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --error-color: #dc2626;
    --status-active: #16a34a;
    --status-legacy: #6b7280;
    --status-halted: #f97316;
    --status-expired: #ef4444;
    --status-pending: #f59e0b;
    --status-exp_grace: #eab308;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    font-size: 1.2rem;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

#loading-overlay.visible {
    display: flex;
}

.admin-header {
    background-color: var(--card-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    height: 40px;
    margin-right: 1rem;
}

.admin-header h1 {
    font-size: 1.5rem;
    margin: 0;
    flex-grow: 1;
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Increased gap for clock */
}

/* NEW: Live Clock Style */
.live-clock {
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
    white-space: nowrap;
}

#logout-button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

#logout-button:hover {
    background-color: var(--primary-color);
    color: white;
}

.admin-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.card h2 {
    font-size: 1.25rem;
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.user-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.user-toolbar input,
.user-toolbar select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.user-toolbar input[type="text"] {
    flex-grow: 1;
    min-width: 250px;
}

.user-toolbar input:focus,
.user-toolbar select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 56, 202, 0.2);
}

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

#user-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

#user-table th,
#user-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

#user-table th {
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

#user-table td {
    vertical-align: middle;
}

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

#user-table a:hover {
    text-decoration: underline;
}

.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    text-transform: capitalize;
}

.status-active { background-color: var(--status-active); }
.status-legacy { background-color: var(--status-legacy); }
.status-halted { background-color: var(--status-halted); }
.status-expired { background-color: var(--status-expired); }
.status-pending { background-color: var(--status-pending); }
.status-exp_grace { background-color: var(--status-exp_grace); }

.button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
    font-size: 1rem;
}

.button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.button:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.button.secondary {
    background-color: #6b7280;
    color: white;
}

.button.secondary:hover:not(:disabled) {
    background-color: #4b5563;
}

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

.button.danger:hover:not(:disabled) {
    background-color: #b91c1c;
}

.button.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

#user-count-display {
    font-size: 0.9rem;
    color: var(--text-light);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay:not(.hidden) .modal-dialog {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--text-dark);
}

#modal-title,
#confirm-modal-title {
    margin-top: 0;
    font-size: 1.25rem;
}

#confirm-modal-text {
    color: var(--text-light);
}

#confirm-modal-text strong {
    color: var(--error-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-light);
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: #f9fafb;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 56, 202, 0.2);
}

.modal-buttons {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}