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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ── Layout ──────────────────────────────────────────── */
header {
    background: #1a1a2e;
    color: #fff;
    padding: 2rem 1.5rem;
    text-align: center;
}

header .header-logo {
    max-height: 80px;
    margin-bottom: 0.5rem;
}

header p {
    color: #aaa;
    font-size: 0.95rem;
}

main {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 0;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card h2 {
    font-size: 1.2rem;
    color: #1a1a2e;
    margin: 0;
}

/* ── Collapsible Card Header ─────────────────────────── */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.card-header:hover {
    background: #fafafa;
}

.chevron {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-right: 2px solid #999;
    border-bottom: 2px solid #999;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-left: 0.75rem;
}

.card.collapsed .chevron {
    transform: rotate(-45deg);
}

/* ── Collapsible Card Body ───────────────────────────── */
.card-body {
    padding: 0 1.5rem 1.5rem;
    max-height: 5000px;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
    opacity: 1;
}

.card.collapsed .card-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="file"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #f6821f;
    box-shadow: 0 0 0 3px rgba(246,130,31,0.15);
}

.form-group small {
    display: block;
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.form-group code {
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
}

button {
    background: #f6821f;
    color: #fff;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover { background: #e0741a; }

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ── Progress Bar ────────────────────────────────────── */
#progress-container { margin-top: 1.25rem; }

.progress-bar {
    background: #eee;
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
}

.progress-fill {
    background: #f6821f;
    height: 100%;
    width: 0%;
    border-radius: 20px;
    transition: width 0.3s ease;
}

#progress-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.4rem;
    text-align: center;
}

/* ── Sites Table ─────────────────────────────────────── */
.sites-table {
    width: 100%;
    border-collapse: collapse;
}

.sites-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid #eee;
}

.sites-table td {
    font-size: 0.85rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}

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

.sites-table tbody tr:hover {
    background: #fafafa;
}

.sites-table .col-center {
    text-align: center;
}

.sites-table .col-nowrap {
    white-space: nowrap;
    color: #888;
    font-size: 0.8rem;
}

.sites-table .col-actions {
    text-align: right;
    white-space: nowrap;
}

.site-link {
    color: #1a1a2e;
    text-decoration: none;
    font-weight: 600;
}

.site-link:hover {
    color: #f6821f;
    text-decoration: underline;
}

.site-table-desc {
    display: block;
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.15rem;
    line-height: 1.3;
}

.badge {
    display: inline-block;
    background: #1a1a2e;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    margin-right: 0.2rem;
    vertical-align: middle;
}

.btn-versions {
    background: #f0f0f0;
    color: #555;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    border-radius: 4px;
    margin-left: 0.3rem;
}

.btn-versions:hover {
    background: #e4e4e4;
    color: #333;
}

.btn-delete {
    background: #d63031;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    border-radius: 4px;
    margin-left: 0.3rem;
}

.btn-delete:hover { background: #b71c1c; }

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #999;
}

/* ── Toast Notifications ─────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast.success { background: #27ae60; }
.toast.error   { background: #d63031; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Activity Log ────────────────────────────────────── */
.audit-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.audit-entry:last-child {
    border-bottom: none;
}

.audit-action {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.audit-action.upload_complete { background: #27ae60; }
.audit-action.delete          { background: #d63031; }
.audit-action.snapshot        { background: #2980b9; }
.audit-action.restore         { background: #8e44ad; }

.audit-user {
    color: #999;
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

.audit-time {
    color: #aaa;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 1rem;
}

.btn-load-more {
    width: 100%;
    margin-top: 0.75rem;
    background: #f0f0f0;
    color: #555;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.55rem;
    border-radius: 6px;
}

.btn-load-more:hover {
    background: #e4e4e4;
    color: #333;
}

/* ── Version History Modal ───────────────────────────── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1.1rem;
    color: #1a1a2e;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
    background: none;
}

.version-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f5f5f5;
}

.version-entry:last-child {
    border-bottom: none;
}

.version-info {
    font-size: 0.85rem;
    color: #333;
}

.version-info .version-date {
    font-weight: 600;
}

.version-info .version-meta {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.15rem;
}

.btn-restore {
    background: #2980b9;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.btn-restore:hover {
    background: #2471a3;
}

/* ── Analytics Dashboard ─────────────────────────────── */
.day-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.day-btn {
    background: #f0f0f0;
    color: #555;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
}

.day-btn:hover {
    background: #e4e4e4;
    color: #333;
}

.day-btn.active {
    background: #1a1a2e;
    color: #fff;
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
}

.analytics-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid #eee;
}

.analytics-table td {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}

.analytics-table tr:last-child td {
    border-bottom: none;
}

.analytics-bar-cell {
    width: 50%;
}

.analytics-bar {
    height: 8px;
    background: #f6821f;
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.3s ease;
}

.analytics-views {
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
}

/* ── Utilities ───────────────────────────────────────── */
.hidden { display: none; }
.muted  { color: #999; font-style: italic; }
