/* ============================================================
   Pucky — Application Styles
   Loading, validation, layout, and utility classes
   ============================================================ */


/* ----------------------------------------------------------
   1. Loading Screen
   ---------------------------------------------------------- */
.pucky-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    z-index: 9999;
    overflow: hidden;
}

/* Subtle background grid pattern */
.pucky-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(79, 124, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(79, 124, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.pucky-logo-loading {
    position: relative;
    width: 72px;
    height: 72px;
    animation: logoPulse 2.4s ease-in-out infinite;
}

.pucky-logo-image {
    width: 72px;
    height: 72px;
    object-fit: contain;
    animation: logoPulse 2.4s ease-in-out infinite;
    filter: drop-shadow(0 0 24px rgba(79, 124, 255, 0.3));
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.06);
        opacity: 0.85;
    }
}

.loading-text {
    position: relative;
    margin-top: 1.75rem;
    font-family: var(--font-sans, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: 1.375rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.loading-spinner {
    position: relative;
    margin-top: 1.25rem;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(79, 124, 255, 0.15);
    border-top-color: #4F7CFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading subtitle */
.loading-subtitle {
    position: relative;
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: #94a3b8;
    font-weight: 400;
    letter-spacing: 0.01em;
}


/* ----------------------------------------------------------
   2. Validation Styles
   ---------------------------------------------------------- */
.valid.modified:not([type=checkbox]) {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.invalid {
    outline: none;
    border-color: #f43f5e !important;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12) !important;
}

.validation-message {
    color: #f43f5e;
    font-size: 0.8125rem;
    font-weight: 450;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.validation-message::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 4px;
    background-color: #f43f5e;
    border-radius: 50%;
    flex-shrink: 0;
}


/* ----------------------------------------------------------
   3. Blazor Error UI
   ---------------------------------------------------------- */
#blazor-error-ui {
    background: linear-gradient(to right, #fff1f2, #ffe4e6);
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    display: none;
    left: 0;
    padding: 0.875rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    color: #9f1239;
    font-weight: 500;
    font-size: 0.875rem;
    border-top: 2px solid #f43f5e;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.5rem;
    font-size: 1.25rem;
    color: #9f1239;
    opacity: 0.6;
    transition: opacity 200ms ease;
    line-height: 1;
    padding: 0.25rem;
}

#blazor-error-ui .dismiss:hover {
    opacity: 1;
}

#blazor-error-ui .reload {
    color: #4F7CFF;
    text-decoration: none;
    font-weight: 600;
    transition: color 200ms ease;
}

#blazor-error-ui .reload:hover {
    color: #2F50C9;
    text-decoration: underline;
}

.blazor-error-boundary {
    background: #fff1f2;
    padding: 1rem 1.25rem 1rem 3rem;
    color: #9f1239;
    border-left: 4px solid #f43f5e;
    margin: 1rem 0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    position: relative;
}

.blazor-error-boundary::before {
    content: "!";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #f43f5e;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}


/* ----------------------------------------------------------
   4. Focus Styles
   ---------------------------------------------------------- */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18);
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid #4F7CFF;
    outline-offset: 1px;
}

/* Remove default focus ring for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}


/* ----------------------------------------------------------
   5. Content Area
   ---------------------------------------------------------- */
.content {
    padding-top: 1.5rem;
}


/* ----------------------------------------------------------
   6. Page Header
   ---------------------------------------------------------- */
.page-header {
    margin-bottom: 1.75rem;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 0.75rem;
    position: relative;
    overflow: hidden;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.page-header:focus,
.page-header:focus-visible,
.page-header *:focus,
.page-header *:focus-visible {
    outline: none;
    box-shadow: none;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(79, 124, 255, 0.15) 100%);
    pointer-events: none;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.3;
    position: relative;
}

.page-header .subtitle {
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 400;
    margin: 0.25rem 0 0;
    line-height: 1.5;
    position: relative;
}

/* Page header with actions */
.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.page-header-row .page-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

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


/* ----------------------------------------------------------
   7. Utility Text Classes
   ---------------------------------------------------------- */
.text-muted {
    color: #64748b !important;
}

.text-primary {
    color: #4F7CFF !important;
}

.text-success {
    color: #10b981 !important;
}

.text-danger {
    color: #f43f5e !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-info {
    color: #0ea5e9 !important;
}

.text-slate {
    color: #475569 !important;
}

.text-heading {
    color: #0f172a !important;
    font-weight: 650;
    letter-spacing: -0.015em;
}

.text-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.text-mono {
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
                 Menlo, Monaco, Consolas, monospace;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ----------------------------------------------------------
   8. Code Element
   ---------------------------------------------------------- */
code {
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
                 Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125em;
    color: #4F7CFF;
    background-color: #EEF3FF;
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-weight: 500;
}

pre code {
    display: block;
    background-color: #0f172a;
    color: #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.7;
    overflow-x: auto;
}

kbd {
    background-color: #1e293b;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15em 0.45em;
    border-radius: 0.25rem;
    border: 1px solid #334155;
    box-shadow: 0 1px 0 #334155;
}


/* ----------------------------------------------------------
   9. Form Floating Label Overrides
   ---------------------------------------------------------- */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}


/* ----------------------------------------------------------
   10. Empty State
   ---------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: #64748b;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.375rem;
}

.empty-state-text {
    font-size: 0.875rem;
    color: #94a3b8;
    max-width: 360px;
    line-height: 1.5;
}


/* ----------------------------------------------------------
   11. Stat / Metric Cards
   ---------------------------------------------------------- */
.stat-value {
    font-size: 1.875rem;
    font-weight: 750;
    letter-spacing: -0.025em;
    color: #0f172a;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.8125rem;
    font-weight: 550;
}

.stat-change.positive {
    color: #10b981;
}

.stat-change.negative {
    color: #f43f5e;
}


/* ----------------------------------------------------------
   12. Dividers
   ---------------------------------------------------------- */
hr, .divider {
    border-color: #e2e8f0;
    opacity: 1;
}

.divider-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.divider-label::before,
.divider-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: #e2e8f0;
}


/* ----------------------------------------------------------
   13. Responsive Adjustments
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 1.375rem;
    }

    .page-header .subtitle {
        font-size: 0.8125rem;
    }

    .page-header-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn {
        flex: 1;
    }

    .stat-value {
        font-size: 1.375rem;
    }

    .empty-state {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 576px) {
    .page-header h1 {
        font-size: 1.25rem;
    }

    .content {
        padding-top: 1rem;
    }
}

@media (min-width: 1400px) {
    .page-header h1 {
        font-size: 2rem;
    }
}


/* ----------------------------------------------------------
   14. Transitions & Animations
   ---------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 300ms ease forwards;
}

.animate-slide-up {
    animation: slideUp 300ms ease forwards;
}

.animate-slide-down {
    animation: slideDown 300ms ease forwards;
}


/* ----------------------------------------------------------
   15. Skeleton Loading
   ---------------------------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-circle {
    border-radius: 50%;
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
