/* ============================================================
   SpeedyInv Admin — Page-Specific Styles
   ============================================================ */

/* ===================== LOGIN PAGE ===================== */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--si-bg-body);
}

.login-brand-panel {
    flex: 1;
    background: var(--si-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.6;
}

.login-brand-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.login-brand-content .brand-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.login-brand-content h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.login-brand-content p {
    font-size: 1rem;
    opacity: 0.8;
    max-width: 320px;
}

.login-form-panel {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.login-form-card {
    width: 100%;
    max-width: 360px;
}

.login-form-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-form-card .subtitle {
    color: var(--si-text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .login-brand-panel { display: none; }
    .login-form-panel { width: 100%; }
}

/* ===================== DASHBOARD ===================== */
.dashboard-welcome {
    margin-bottom: 1.5rem;
}

.dashboard-welcome h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.dashboard-welcome p {
    color: var(--si-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

.dashboard-chart-card canvas {
    max-height: 280px;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.quick-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background: var(--si-bg-surface-alt);
    border: 1px solid var(--si-border);
    text-decoration: none;
    color: var(--si-text);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.12s;
}

.quick-action-item:hover {
    border-color: var(--si-primary);
    background: var(--si-primary-subtle);
    color: var(--si-primary-text);
}

.quick-action-item i {
    font-size: 1.25rem;
    color: var(--si-primary);
}

/* Health indicator */
.health-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot.green { background: var(--si-success); box-shadow: 0 0 6px var(--si-success); }
.health-dot.yellow { background: var(--si-warning); box-shadow: 0 0 6px var(--si-warning); }
.health-dot.red { background: var(--si-danger); box-shadow: 0 0 6px var(--si-danger); }

/* ===================== LOG PAGES ===================== */
.log-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.log-timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--si-border);
}

.log-entry {
    position: relative;
    padding: 0.75rem 0 0.75rem 1rem;
    border-bottom: 1px solid var(--si-border-light);
}

.log-entry::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 1.125rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--si-border);
    border: 2px solid var(--si-bg-surface);
    z-index: 1;
}

.log-entry.severity-info::before { background: var(--si-info); }
.log-entry.severity-warning::before { background: var(--si-warning); }
.log-entry.severity-error::before { background: var(--si-danger); }

.log-entry-time {
    font-size: 0.75rem;
    color: var(--si-text-muted);
    margin-bottom: 0.25rem;
}

.log-entry-message {
    font-size: 0.875rem;
    color: var(--si-text);
}

.log-entry-meta {
    font-size: 0.75rem;
    color: var(--si-text-muted);
    margin-top: 0.25rem;
}

/* Stack trace expandable */
.stack-trace {
    background: var(--si-bg-code);
    border: 1px solid var(--si-border);
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
    color: var(--si-text-secondary);
    max-height: 200px;
    overflow-y: auto;
}

/* ===================== SETTINGS PAGE ===================== */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.settings-section .section-desc {
    font-size: 0.8125rem;
    color: var(--si-text-muted);
    margin-bottom: 1rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--si-border-light);
    gap: 1rem;
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-label {
    flex: 1;
}

.settings-row-label strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
}

.settings-row-label span {
    font-size: 0.8125rem;
    color: var(--si-text-muted);
}

/* ===================== ROLES / PERMISSIONS ===================== */
.permission-module {
    background: var(--si-bg-surface);
    border: 1px solid var(--si-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.permission-module-header {
    padding: 0.75rem 1rem;
    background: var(--si-bg-surface-alt);
    border-bottom: 1px solid var(--si-border);
    font-weight: 600;
    font-size: 0.875rem;
}

.permission-module-body {
    padding: 0.75rem 1rem;
}

.permission-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.8125rem;
}

.permission-item label {
    color: var(--si-text-secondary);
}

/* ===================== PACKAGES / PLANS ===================== */
.plan-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

.plan-card {
    background: var(--si-bg-surface);
    border: 1px solid var(--si-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.plan-card:hover {
    box-shadow: var(--si-shadow-md);
}

.plan-card.plan-inactive {
    opacity: 0.6;
}

.plan-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.plan-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
}

.plan-card-slug {
    font-size: 0.75rem;
    color: var(--si-text-muted);
    font-family: monospace;
}

.plan-card-actions-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.plan-card-desc {
    font-size: 0.8125rem;
    color: var(--si-text-secondary);
    margin: 0;
    line-height: 1.5;
}

.plan-card-pricing {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.plan-price {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--si-primary);
    line-height: 1.2;
}

.plan-price small {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--si-text-muted);
}

.plan-price-yearly {
    font-size: 0.8125rem;
    color: var(--si-text-muted);
}

.plan-card-limits {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--si-border-light);
    border-bottom: 1px solid var(--si-border-light);
}

.plan-limit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

.plan-limit-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--si-text);
}

.plan-limit-label {
    font-size: 0.6875rem;
    color: var(--si-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.plan-card-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* ===================== ROLES & PERMISSIONS ===================== */
.roles-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 991.98px) {
    .roles-layout { grid-template-columns: 1fr; }
}

.roles-list-card {
    padding: 0;
    overflow: hidden;
}

.roles-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--si-border-light);
}

.roles-list-header h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 0;
}

.roles-list {
    max-height: 60vh;
    overflow-y: auto;
}

.role-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid var(--si-border-light);
    transition: background 0.1s;
}

.role-item:last-child { border-bottom: none; }

.role-item:hover { background: var(--si-bg-hover); }

.role-item.active {
    background: var(--si-primary-subtle);
    border-left: 3px solid var(--si-primary);
    padding-left: calc(1.25rem - 3px);
}

.role-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.role-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--si-text);
}

.role-item-slug {
    font-size: 0.75rem;
    color: var(--si-text-muted);
    font-family: monospace;
}

.role-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.permissions-card {
    padding: 0;
    overflow: hidden;
}

.permissions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--si-border-light);
    gap: 1rem;
}

.permissions-header h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 0;
}

.permissions-desc {
    font-size: 0.8125rem;
    color: var(--si-text-muted);
    margin: 0.25rem 0 0;
}

.permissions-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.permissions-body {
    padding: 1.25rem;
    max-height: 65vh;
    overflow-y: auto;
}

.permission-module {
    margin-bottom: 1.25rem;
}

.permission-module:last-child { margin-bottom: 0; }

.permission-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.625rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--si-border-light);
}

.permission-module-header h4 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: capitalize;
    margin: 0;
}

.permission-module-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.375rem;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.1s;
}

.permission-item:hover {
    background: var(--si-bg-hover);
}

.permission-item input[type=checkbox] {
    position: relative;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.permission-item .si-toggle-slider {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background: var(--si-bg-input);
    border: 2px solid var(--si-border);
    border-radius: 0.25rem;
    transition: 0.15s;
}

.permission-item .si-toggle-slider::before {
    content: none;
}

.permission-item input:checked + .si-toggle-slider {
    background: var(--si-primary);
    border-color: var(--si-primary);
}

.permission-item input:checked + .si-toggle-slider::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.permission-item-text {
    display: flex;
    flex-direction: column;
    gap: 0.0625rem;
    min-width: 0;
}

.permission-item-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--si-text);
}

.permission-item-slug {
    font-size: 0.6875rem;
    color: var(--si-text-muted);
}

/* ===================== TRANSLATIONS ===================== */
.translation-table td.editable {
    cursor: text;
}

.translation-table td.editable:hover {
    background: var(--si-primary-subtle);
}

.translation-table td.editing {
    padding: 0.25rem 0.5rem;
}

.translation-table td.editing input {
    width: 100%;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--si-primary);
    border-radius: 0.25rem;
    background: var(--si-bg-input);
    color: var(--si-text);
    font-size: 0.875rem;
}

/* ===================== SUBSCRIPTIONS ===================== */
.sub-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.sub-status-badge.active { background: var(--si-success-subtle); color: var(--si-success-text); }
.sub-status-badge.trial { background: var(--si-info-subtle); color: var(--si-info-text); }
.sub-status-badge.cancelled { background: var(--si-danger-subtle); color: var(--si-danger-text); }
.sub-status-badge.expired { background: var(--si-bg-badge); color: var(--si-text-muted); }

/* ===================== EMAIL TEMPLATES ===================== */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.template-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-group-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--si-text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-group-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-card {
    background: var(--si-bg-surface);
    border: 1px solid var(--si-border);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: all 0.12s;
}

.template-card:hover {
    border-color: var(--si-primary);
}

.template-info h6 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.template-info p {
    font-size: 0.8125rem;
    color: var(--si-text-muted);
    margin: 0;
}

.template-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

/* ===================== RESPONSIVE TWEAKS ===================== */
@media (max-width: 576px) {
    .admin-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .si-filter-bar { flex-direction: column; align-items: stretch; }
    .si-filter-bar .si-form-control,
    .si-filter-bar .si-form-select { width: 100%; min-width: unset; }
}
