/* ========================================
   AlpacApps — Shared Admin Styles
   Auth widget, admin layout, tables, modals

   Theming: Override --aap-* variables in your project's stylesheet.
   All values fall back to sensible defaults.
   ======================================== */

:root {
    /* Auth & admin theme — override these in your project CSS */
    --aap-accent: #7B1A2C;
    --aap-accent-deep: #5A0F1E;
    --aap-accent-light: #9E2B3F;
    --aap-gold: #D4A843;
    --aap-gold-dim: #B8923A;
    --aap-bg: #FBF8F1;
    --aap-bg-warm: #F5EFE2;
    --aap-surface: #FFFFFF;
    --aap-surface-warm: #FFFDF9;
    --aap-text: #2A1F1A;
    --aap-text-soft: #5C4A3E;
    --aap-text-dim: #8A7668;
    --aap-text-muted: #B0A090;
    --aap-border: #E8DFD0;
    --aap-border-light: #F0EAE0;
    --aap-radius: 12px;
    --aap-radius-lg: 20px;
    --aap-radius-xl: 28px;
    --aap-shadow-sm: 0 1px 3px rgba(28,20,16,0.06), 0 1px 2px rgba(28,20,16,0.04);
    --aap-shadow-md: 0 4px 12px rgba(28,20,16,0.08), 0 2px 4px rgba(28,20,16,0.04);
    --aap-shadow-lg: 0 12px 40px rgba(28,20,16,0.12), 0 4px 12px rgba(28,20,16,0.06);
    --aap-shadow-xl: 0 20px 60px rgba(28,20,16,0.15), 0 8px 20px rgba(28,20,16,0.08);
    --aap-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======================================== Auth Widget (Profile / Login) ======================================== */
.auth-widget {
    position: relative; margin-left: 4px; order: 10;
}

/* Logged-out: circle icon button */
.auth-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(123,26,44,0.04); border: 1px solid var(--aap-border);
    cursor: pointer; color: var(--aap-text-soft); transition: all var(--aap-transition);
}
.auth-btn:hover { border-color: var(--aap-gold); color: var(--aap-accent); background: rgba(212,168,67,0.06); }
.auth-btn svg { flex-shrink: 0; }

/* Logged-in: initials avatar */
.auth-avatar {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    cursor: pointer; transition: all var(--aap-transition); flex-shrink: 0;
    font-family: inherit;
}
.auth-avatar--initials {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--aap-accent); color: #fff; font-size: 12px; font-weight: 600;
    user-select: none; letter-spacing: 0.03em;
}
.auth-avatar--initials:hover { background: var(--aap-accent-deep); box-shadow: 0 0 0 3px rgba(123,26,44,0.15); }

/* Auth dropdown */
.auth-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 1001;
    min-width: 180px; background: var(--aap-surface);
    border: 1px solid var(--aap-border); border-radius: var(--aap-radius);
    box-shadow: var(--aap-shadow-lg); padding: 6px 0;
    opacity: 0; pointer-events: none; transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.auth-dropdown--open { opacity: 1; pointer-events: auto; transform: translateY(0); }

.auth-dropdown__user {
    padding: 10px 16px 8px; font-size: 13px; font-weight: 600;
    color: var(--aap-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auth-dropdown__divider {
    height: 1px; background: var(--aap-border-light); margin: 4px 0;
}
.auth-dropdown__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 16px; background: none; border: none;
    cursor: pointer; font-family: inherit; font-size: 14px;
    color: var(--aap-text-soft); text-align: left; text-decoration: none; transition: all var(--aap-transition);
}
.auth-dropdown__item:hover { background: rgba(212,168,67,0.06); color: var(--aap-accent); }
.auth-dropdown__signout { color: var(--aap-accent-light); }
.auth-dropdown__signout:hover { background: rgba(123,26,44,0.04); color: var(--aap-accent-deep); }

/* ======================================== Login Modal ======================================== */
.auth-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.25s ease;
}
.auth-modal--open { opacity: 1; }
.auth-modal__backdrop {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(28,20,16,0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.auth-modal__card {
    position: relative; width: 100%; max-width: 400px; margin: 24px;
    background: var(--aap-surface); border: 1px solid var(--aap-border);
    border-radius: var(--aap-radius-xl); padding: 40px 36px;
    box-shadow: var(--aap-shadow-xl); transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-modal--open .auth-modal__card { transform: translateY(0); }
.auth-modal__close {
    position: absolute; top: 16px; right: 16px; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer;
    font-size: 24px; color: var(--aap-text-muted); transition: color var(--aap-transition);
    border-radius: 50%; line-height: 1;
}
.auth-modal__close:hover { color: var(--aap-text); background: var(--aap-bg-warm); }
.auth-modal__header { text-align: center; margin-bottom: 28px; }
.auth-modal__title {
    font-size: 1.6rem; font-weight: 600; color: var(--aap-accent-deep); margin-bottom: 6px;
}
.auth-modal__subtitle { font-size: 14px; color: var(--aap-text-dim); }
.auth-modal__form { display: flex; flex-direction: column; gap: 18px; }
.auth-modal__field { display: flex; flex-direction: column; gap: 6px; }
.auth-modal__field label { font-size: 13px; font-weight: 600; color: var(--aap-text-soft); }
.auth-modal__field input {
    padding: 11px 14px; border: 1.5px solid var(--aap-border); border-radius: var(--aap-radius);
    font-family: inherit; font-size: 14px; color: var(--aap-text);
    background: var(--aap-surface-warm); outline: none;
    transition: border-color var(--aap-transition), box-shadow var(--aap-transition);
}
.auth-modal__field input:focus {
    border-color: var(--aap-gold); box-shadow: 0 0 0 3px rgba(212,168,67,0.1);
}
.auth-modal__field input::placeholder { color: var(--aap-text-muted); }
.auth-modal__error { font-size: 13px; color: #dc2626; min-height: 0; text-align: center; }
.auth-modal__error:empty { display: none; }
.auth-modal__submit {
    width: 100%; padding: 14px; font-size: 15px; font-weight: 600;
    background: var(--aap-accent); color: #fff; border: none; border-radius: 100px;
    cursor: pointer; transition: background var(--aap-transition);
    font-family: inherit;
}
.auth-modal__submit:hover { background: var(--aap-accent-deep); }
.auth-modal__submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* Google OAuth */
.auth-modal__google { margin-bottom: 4px; }
.auth-modal__google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 11px 16px; border: 1px solid #dadce0; border-radius: 8px;
    background: #fff; color: #3c4043; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.auth-modal__google-btn:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.auth-modal__divider {
    display: flex; align-items: center; gap: 12px;
    color: #9ca3af; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
    margin: 4px 0;
}
.auth-modal__divider::before,
.auth-modal__divider::after { content: ''; flex: 1; height: 1px; background: #e5e7eb; }

/* Mobile auth */
@media (max-width: 768px) {
    .auth-widget { position: absolute; top: 14px; right: 16px; margin-left: 0; }
    .auth-dropdown { right: 0; }
    .auth-modal__card { padding: 32px 24px; margin: 16px; }
}

/* ======================================== Admin Layout ======================================== */
.admin-layout { padding-top: 100px; min-height: 100vh; }
.admin-topbar {
    position: fixed; top: 60px; left: 0; right: 0; z-index: 999;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: rgba(255,255,255,0.9); display: flex; align-items: center;
    justify-content: space-between; padding: 0 24px; height: 40px;
    font-size: 12px; font-weight: 600; letter-spacing: 0.05em;
}
.admin-topbar__label { opacity: 0.6; }
.admin-topbar__nav { display: flex; gap: 4px; }
.admin-topbar__nav a {
    padding: 6px 14px; border-radius: 100px; font-size: 12px; font-weight: 600;
    color: rgba(255,255,255,0.55); text-decoration: none; transition: all var(--aap-transition);
}
.admin-topbar__nav a:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.08); }
.admin-topbar__nav a.active { color: #fff; background: rgba(255,255,255,0.12); }

.admin-container { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.admin-page-header { margin-bottom: 32px; }
.admin-page-header h1 { font-size: 2rem; font-weight: 600; color: var(--aap-accent-deep); margin-bottom: 4px; }
.admin-page-header p { font-size: 14px; color: var(--aap-text-dim); }

/* ======================================== Dashboard Stat Cards ======================================== */
.admin-stats {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.admin-stat {
    background: var(--aap-surface); border: 1px solid var(--aap-border);
    border-radius: var(--aap-radius-lg); padding: 24px; transition: all var(--aap-transition);
}
.admin-stat:hover { box-shadow: var(--aap-shadow-md); transform: translateY(-2px); }
.admin-stat__icon { font-size: 28px; margin-bottom: 12px; }
.admin-stat__value { font-size: 2rem; font-weight: 700; color: var(--aap-text); line-height: 1; }
.admin-stat__label { font-size: 13px; color: var(--aap-text-dim); margin-top: 4px; }

/* ======================================== Admin Card Grid ======================================== */
.admin-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.admin-card {
    display: flex; align-items: flex-start; gap: 16px; padding: 24px;
    background: var(--aap-surface); border: 1px solid var(--aap-border);
    border-radius: var(--aap-radius-lg); text-decoration: none;
    transition: all var(--aap-transition); cursor: pointer;
}
.admin-card:hover { box-shadow: var(--aap-shadow-lg); border-color: var(--aap-gold); transform: translateY(-4px); }
.admin-card__icon {
    width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(123,26,44,0.06), rgba(212,168,67,0.08));
    border-radius: 14px; font-size: 24px; flex-shrink: 0;
}
.admin-card__title { font-size: 16px; font-weight: 700; color: var(--aap-text); margin-bottom: 4px; }
.admin-card__desc { font-size: 13px; color: var(--aap-text-dim); line-height: 1.5; }

/* ======================================== Admin Data Table ======================================== */
.admin-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.admin-toolbar__search {
    flex: 1; min-width: 200px; max-width: 360px;
    padding: 9px 14px; border: 1.5px solid var(--aap-border); border-radius: var(--aap-radius);
    font-family: inherit; font-size: 14px; color: var(--aap-text);
    background: var(--aap-surface-warm); outline: none; transition: border-color var(--aap-transition);
}
.admin-toolbar__search:focus { border-color: var(--aap-gold); box-shadow: 0 0 0 3px rgba(212,168,67,0.1); }
.admin-toolbar__actions { display: flex; gap: 8px; }

.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 24px; }
.admin-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--aap-surface); border: 1px solid var(--aap-border);
    border-radius: var(--aap-radius-lg); overflow: hidden; font-size: 14px;
}
.admin-table thead th {
    padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700;
    color: var(--aap-text-dim); letter-spacing: 0.05em; text-transform: uppercase;
    background: var(--aap-bg-warm); border-bottom: 2px solid var(--aap-border);
    white-space: nowrap;
}
.admin-table tbody td {
    padding: 12px 16px; border-bottom: 1px solid var(--aap-border-light);
    color: var(--aap-text-soft); vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(212,168,67,0.03); }

/* ======================================== Badges ======================================== */
.admin-badge {
    display: inline-flex; padding: 3px 10px; border-radius: 100px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
}
.admin-badge--active { background: #dcfce7; color: #166534; }
.admin-badge--inactive { background: #f3f4f6; color: #6b7280; }
.admin-badge--pending { background: #fef3c7; color: #92400e; }
.admin-badge--income { background: #dcfce7; color: #166534; }
.admin-badge--expense { background: #fef2f2; color: #991b1b; }

/* ======================================== Table Actions ======================================== */
.admin-table__actions { display: flex; gap: 4px; }
.admin-table__actions button {
    padding: 5px 10px; border: 1px solid var(--aap-border); border-radius: 6px;
    background: none; cursor: pointer; font-size: 12px; font-weight: 600;
    color: var(--aap-text-dim); font-family: inherit; transition: all var(--aap-transition);
}
.admin-table__actions button:hover { border-color: var(--aap-gold); color: var(--aap-accent); background: rgba(212,168,67,0.06); }

/* ======================================== Small Button ======================================== */
.btn-sm {
    padding: 8px 18px; font-size: 13px; border-radius: 100px;
    font-family: inherit; font-weight: 600; cursor: pointer;
    border: none; transition: all var(--aap-transition); text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-sm.btn-primary { background: var(--aap-accent); color: #fff; }
.btn-sm.btn-primary:hover { background: var(--aap-accent-deep); }

/* ======================================== Empty State ======================================== */
.admin-empty { text-align: center; padding: 48px 24px; color: var(--aap-text-dim); }
.admin-empty__icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.admin-empty__text { font-size: 15px; }

/* ======================================== Admin Modal ======================================== */
.admin-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 80px; opacity: 0; transition: opacity 0.25s ease;
    pointer-events: none;
}
.admin-modal--open { opacity: 1; pointer-events: auto; }
.admin-modal__backdrop {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(28,20,16,0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.admin-modal__card {
    position: relative; width: 100%; max-width: 560px; margin: 24px;
    background: var(--aap-surface); border: 1px solid var(--aap-border);
    border-radius: var(--aap-radius-xl); padding: 36px;
    box-shadow: var(--aap-shadow-xl); max-height: calc(100vh - 120px); overflow-y: auto;
    transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.admin-modal--open .admin-modal__card { transform: translateY(0); }
.admin-modal__title {
    font-size: 1.5rem; font-weight: 600; color: var(--aap-accent-deep); margin-bottom: 24px;
}
.admin-modal__form { display: flex; flex-direction: column; gap: 16px; }
.admin-modal__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-modal__field { display: flex; flex-direction: column; gap: 5px; }
.admin-modal__field label {
    font-size: 12px; font-weight: 600; color: var(--aap-text-dim);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.admin-modal__field input,
.admin-modal__field select,
.admin-modal__field textarea {
    padding: 10px 12px; border: 1.5px solid var(--aap-border); border-radius: var(--aap-radius);
    font-family: inherit; font-size: 14px; color: var(--aap-text);
    background: var(--aap-surface-warm); outline: none;
    transition: border-color var(--aap-transition), box-shadow var(--aap-transition);
}
.admin-modal__field input:focus,
.admin-modal__field select:focus,
.admin-modal__field textarea:focus {
    border-color: var(--aap-gold); box-shadow: 0 0 0 3px rgba(212,168,67,0.1);
}
.admin-modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.admin-modal__actions .btn-cancel {
    padding: 10px 20px; background: none; border: 1.5px solid var(--aap-border); border-radius: 100px;
    font-family: inherit; font-size: 14px; font-weight: 600;
    color: var(--aap-text-dim); cursor: pointer; transition: all var(--aap-transition);
}
.admin-modal__actions .btn-cancel:hover { border-color: var(--aap-text-muted); color: var(--aap-text); }

/* ======================================== Filter Tabs ======================================== */
.admin-filters { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-filter-btn {
    padding: 7px 16px; border: 1px solid var(--aap-border); border-radius: 100px;
    background: none; font-family: inherit; font-size: 13px;
    font-weight: 600; color: var(--aap-text-dim); cursor: pointer; transition: all var(--aap-transition);
}
.admin-filter-btn:hover { border-color: var(--aap-gold); color: var(--aap-accent); }
.admin-filter-btn.active { background: var(--aap-accent); color: #fff; border-color: var(--aap-accent); }

/* ======================================== Responsive ======================================== */
@media (max-width: 640px) {
    .admin-topbar { flex-direction: column; height: auto; padding: 8px 16px; gap: 4px; }
    .admin-topbar__nav { flex-wrap: wrap; justify-content: center; }
    .admin-layout { padding-top: 120px; }
    .admin-toolbar { flex-direction: column; }
    .admin-toolbar__search { max-width: 100%; }
    .admin-modal__row { grid-template-columns: 1fr; }
}
