/* ================================================================
   DASHBOARD — Account System
   Isolated stylesheet for dashboard.html. Reuses CSS variables
   (--primary, --accent, --border, --radius, --shadow-*, etc.)
   already defined in style.css's :root, so visuals stay consistent
   with the rest of the site without duplicating base rules.
   ================================================================ */

.dash-container {
    max-width: 980px;
    margin: 0 auto;
    padding: 32px 20px 100px;
}

.dash-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

/* --- Logged-out hero --- */
.dash-hero-card {
    text-align: center;
    max-width: 560px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.dash-hero-icon { font-size: 48px; color: var(--accent); }
.dash-hero-card h1 { font-size: 26px; font-weight: 800; color: var(--primary); margin: 0; }
.dash-hero-card p { color: var(--text-muted); font-size: 15px; line-height: 1.6; margin: 0; }

.btn-google-signin {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 22px;
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.btn-google-signin:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15); transform: translateY(-1px); }
.btn-google-signin img { width: 20px; height: 20px; }

.dash-error { color: var(--danger, #ef4444); font-size: 13px; font-weight: 600; }

.dash-hero-note {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--accent-light);
    padding: 10px 16px;
    border-radius: 8px;
    margin-top: 6px;
}

/* --- Logged-in top bar --- */
.dash-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.dash-user-chip { display: flex; align-items: center; gap: 12px; }
.dash-user-photo {
    width: 46px; height: 46px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--border);
    background: var(--accent-light);
}
.dash-user-name { font-weight: 800; color: var(--primary); font-size: 15px; }
.dash-user-email { color: var(--text-muted); font-size: 13px; }

.btn-signout {
    display: flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid var(--border);
    color: var(--text-muted); border-radius: 8px;
    padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.btn-signout:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }

/* --- Stats row --- */
.dash-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.dash-stat-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
.dash-stat-chip i { font-size: 24px; color: var(--accent); flex-shrink: 0; }
.dash-stat-value { font-weight: 800; color: var(--primary); font-size: 18px; line-height: 1.2; }
.dash-stat-label { color: var(--text-muted); font-size: 12px; font-weight: 600; }

/* --- Grid of cards --- */
.dash-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-card-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 800; font-size: 16px; color: var(--primary); margin-bottom: 4px;
}
.dash-card-sub { color: var(--text-muted); font-size: 13px; margin: 4px 0 18px; line-height: 1.5; }

.dash-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-form-group { display: flex; flex-direction: column; gap: 6px; }
.dash-form-group label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.dash-form-group input, .dash-form-group select {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 14px; color: var(--text-main, #1e293b); outline: none;
}
.dash-form-group input:focus, .dash-form-group select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-save-profile, .btn-upload-sig {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 18px; background: var(--accent); color: #fff; border: none;
    border-radius: 8px; padding: 11px 16px; font-weight: 700; font-size: 14px; cursor: pointer;
    width: 100%;
}
.btn-save-profile:hover, .btn-upload-sig:hover { background: var(--primary-hover); }

.dash-sig-actions { display: flex; gap: 8px; align-items: stretch; }
.dash-sig-actions .btn-upload-sig { margin-top: 0; flex: 1; }
.btn-remove-sig {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #fef2f2; color: #ef4444; border: 1px solid #fecaca;
    border-radius: 8px; padding: 0 14px; cursor: pointer; font-size: 15px;
}
.btn-remove-sig:hover { background: #ef4444; color: #fff; }
.dash-save-msg { font-size: 12px; margin-top: 8px; min-height: 14px; color: #10b981; font-weight: 700; }
.dash-save-msg.error { color: #ef4444; }

.dash-sig-preview {
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-light, #eff6ff); border: 1px dashed var(--border);
    border-radius: 10px; height: 120px; margin-bottom: 4px; overflow: hidden;
}
.dash-sig-empty { color: var(--text-muted); font-size: 13px; }
.dash-sig-preview img { max-height: 100%; max-width: 100%; object-fit: contain; }

/* --- History --- */
.dash-count-badge {
    background: var(--accent-light); color: var(--accent);
    font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; margin-left: 4px;
}
.dash-history-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.btn-clear-history {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
    background: transparent; color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: 12px; cursor: pointer;
}
.btn-clear-history:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }

.dash-history-search {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--border); border-radius: 8px;
    padding: 9px 12px; margin: 14px 0 16px;
    color: var(--text-muted);
}
.dash-history-search i { font-size: 15px; flex-shrink: 0; }
.dash-history-search input {
    border: none; outline: none; font-family: inherit; font-size: 13px;
    width: 100%; background: transparent; color: var(--text-main, #1e293b);
}

.dash-history-list { display: flex; flex-direction: column; gap: 10px; }
.dash-history-item {
    display: flex; align-items: center; gap: 14px;
    border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.dash-history-icon { font-size: 20px; color: var(--accent); flex-shrink: 0; }
.dash-history-info { flex: 1; min-width: 0; }
.dash-history-title { font-weight: 700; color: var(--primary); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-history-meta { color: var(--text-muted); font-size: 12px; }
.dash-history-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-duplicate {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
    background: var(--accent-light); color: var(--accent); border: none;
    border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 12px; cursor: pointer;
    text-decoration: none;
}
.btn-duplicate:hover { background: var(--accent); color: #fff; }
.btn-history-delete {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    background: transparent; color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 14px;
}
.btn-history-delete:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }

.dash-empty-state {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    color: var(--text-muted); font-size: 13px; padding: 30px 0;
}

/* --- Loading --- */
.dash-loading { display: flex; justify-content: center; padding: 60px 0; }
.dash-loading .spinner,
.spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: dash-spin 0.8s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }

.nav-account-chip.active-page { background: var(--primary); }

/* ================================================================
   RESPONSIVE — matches the site-wide 849px breakpoint in style.css
   ================================================================ */
@media (max-width: 849px) {
    .dash-container { padding: 20px 14px 90px; }

    .dash-card { padding: 18px; }

    .dash-hero-card { margin: 20px auto; padding: 24px 20px; }
    .dash-hero-icon { font-size: 38px; }
    .dash-hero-card h1 { font-size: 21px; }
    .dash-hero-card p { font-size: 14px; }
    .btn-google-signin { width: 100%; justify-content: center; }

    .dash-stats-row { grid-template-columns: 1fr; gap: 10px; }
    .dash-stat-chip { padding: 12px 14px; }

    .dash-topbar { flex-direction: column; align-items: stretch; }
    .dash-user-chip { justify-content: flex-start; }
    .btn-signout { align-self: flex-start; }

    .dash-grid { grid-template-columns: 1fr; gap: 14px; }

    .dash-form-grid { grid-template-columns: 1fr; gap: 12px; }

    .dash-sig-preview { height: 100px; }

    .dash-history-header { flex-direction: row; justify-content: space-between; }
    .dash-history-item { flex-wrap: wrap; gap: 10px; padding: 12px; }
    .dash-history-info { flex-basis: 100%; order: 1; }
    .dash-history-icon { order: 0; }
    .dash-history-actions { order: 2; margin-left: auto; }
}

@media (max-width: 480px) {
    .dash-user-name { font-size: 14px; }
    .dash-user-email { font-size: 12px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .dash-card-title { font-size: 15px; }
    .btn-clear-history span { display: none; }
    .dash-history-title { white-space: normal; }
}
