/* ==========================================================================
   Solace Manufacturing Dashboard — Custom Styles
   Supplements Tailwind CSS with glassmorphism, animations, and polish.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */

:root {
    --mfg-dark: #0f1117;
    --mfg-sidebar: #161822;
    --mfg-card: #1e2030;
    --mfg-border: #2e3148;
    --mfg-accent: #06b6d4;
    --mfg-accent-hover: #0891b2;
    --glass-bg: rgba(30, 32, 48, 0.7);
    --glass-border: rgba(46, 49, 72, 0.6);
    --glass-blur: 12px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* --------------------------------------------------------------------------
   Glassmorphism Card System
   -------------------------------------------------------------------------- */

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    transition: border-color var(--transition-normal),
                box-shadow var(--transition-normal),
                transform var(--transition-normal);
}

.glass-card:hover {
    border-color: rgba(6, 182, 212, 0.25);
    box-shadow: 0 4px 30px rgba(6, 182, 212, 0.06);
}

.glass-card-interactive:hover {
    transform: translateY(-1px);
    border-color: rgba(6, 182, 212, 0.35);
    box-shadow: 0 8px 32px rgba(6, 182, 212, 0.1);
}

/* --------------------------------------------------------------------------
   Stat Card Accent Bars
   -------------------------------------------------------------------------- */

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 0.75rem 0.75rem 0 0;
}

.stat-card-cyan::before {
    background: linear-gradient(90deg, #06b6d4, #0891b2);
}

.stat-card-green::before {
    background: linear-gradient(90deg, #10b981, #059669);
}

.stat-card-purple::before {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.stat-card-amber::before {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.stat-card-rose::before {
    background: linear-gradient(90deg, #f43f5e, #e11d48);
}

/* --------------------------------------------------------------------------
   Form Input Focus Glow
   -------------------------------------------------------------------------- */

.form-input {
    background: rgba(31, 41, 55, 0.8);
    border: 1px solid var(--mfg-border);
    color: #d1d5db;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--mfg-accent);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.form-input::placeholder {
    color: #4b5563;
}

/* Tailwind select/input overrides for consistency */
select.form-input {
    padding-right: 2rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
}

textarea.form-input {
    min-height: 100px;
    resize: vertical;
}

/* --------------------------------------------------------------------------
   Data Tables
   -------------------------------------------------------------------------- */

.data-table {
    width: 100%;
    font-size: 0.875rem;
}

.data-table thead tr {
    border-bottom: 1px solid var(--mfg-border);
}

.data-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(46, 49, 72, 0.4);
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(6, 182, 212, 0.04);
}

.data-table tbody td {
    padding: 0.625rem 1rem;
}

/* --------------------------------------------------------------------------
   Status Badges
   -------------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
}

.badge-open      { background: rgba(6, 182, 212, 0.15);   color: #67e8f9; }
.badge-submitted { background: rgba(139, 92, 246, 0.15);  color: #c4b5fd; }
.badge-accepted  { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; }
.badge-rejected  { background: rgba(239, 68, 68, 0.15);   color: #fca5a5; }
.badge-active    { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; }
.badge-probation { background: rgba(245, 158, 11, 0.15);  color: #fcd34d; }
.badge-suspended { background: rgba(249, 115, 22, 0.15);  color: #fdba74; }
.badge-disqualified { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge-received  { background: rgba(6, 182, 212, 0.15);   color: #67e8f9; }
.badge-in_process { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-finished  { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; }
.badge-shipped   { background: rgba(59, 130, 246, 0.15);  color: #93c5fd; }
.badge-quarantined { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

.badge-incoming  { background: rgba(59, 130, 246, 0.15);  color: #93c5fd; }
.badge-in_process_type { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-final     { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; }

.badge-accept    { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; font-weight: 700; }
.badge-reject    { background: rgba(239, 68, 68, 0.15);   color: #fca5a5; font-weight: 700; }
.badge-conditional { background: rgba(245, 158, 11, 0.15); color: #fcd34d; font-weight: 700; }

.badge-conforming   { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; }
.badge-observation  { background: rgba(59, 130, 246, 0.15);  color: #93c5fd; }
.badge-minor_nc     { background: rgba(245, 158, 11, 0.15);  color: #fcd34d; }
.badge-major_nc     { background: rgba(239, 68, 68, 0.15);   color: #fca5a5; }
.badge-completed    { background: rgba(16, 185, 129, 0.15);  color: #6ee7b7; }
.badge-in_progress  { background: rgba(245, 158, 11, 0.15);  color: #fcd34d; }

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */

#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 360px;
}

.toast {
    pointer-events: auto;
    background: rgba(30, 32, 48, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #d1d5db;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s ease;
}

.toast-success { border-left: 3px solid #10b981; }
.toast-error   { border-left: 3px solid #ef4444; }
.toast-info    { border-left: 3px solid #06b6d4; }
.toast-warning { border-left: 3px solid #f59e0b; }

.toast-icon {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
}

.toast-close {
    margin-left: auto;
    flex-shrink: 0;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: #d1d5db;
}

.toast-exit {
    animation: toastSlideOut 0.25s ease forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

/* --------------------------------------------------------------------------
   Loading Skeleton Pulse
   -------------------------------------------------------------------------- */

.skeleton-pulse {
    background: linear-gradient(90deg, #1e2030 25%, #2e3148 50%, #1e2030 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

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

/* --------------------------------------------------------------------------
   Page Content Transition
   -------------------------------------------------------------------------- */

.page-content {
    animation: pageContentFadeIn 0.35s ease;
}

@keyframes pageContentFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Sidebar Collapse
   -------------------------------------------------------------------------- */

aside {
    transition: width var(--transition-normal);
}

.sidebar-collapsed {
    width: 64px !important;
}

.sidebar-collapsed .sidebar-text {
    display: none;
}

.sidebar-collapsed .sidebar-logo-text {
    display: none;
}

.sidebar-collapsed .sidebar-section-label {
    display: none;
}

.sidebar-collapsed nav a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-collapsed nav a svg {
    margin-right: 0;
}

/* Sidebar toggle button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 0.375rem;
    color: #6b7280;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #d1d5db;
}

/* --------------------------------------------------------------------------
   Mobile Responsive Sidebar
   -------------------------------------------------------------------------- */

.sidebar-overlay {
    display: none;
}

.mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {
    aside {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    aside.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .mobile-menu-btn {
        display: flex;
    }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0891b2, #0e7490);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.btn-secondary {
    background: transparent;
    color: #d1d5db;
    border: 1px solid var(--mfg-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

/* --------------------------------------------------------------------------
   Section Headers
   -------------------------------------------------------------------------- */

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

.section-header h2,
.section-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

/* --------------------------------------------------------------------------
   Copy-to-Clipboard Button
   -------------------------------------------------------------------------- */

.copy-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    color: #6b7280;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

.copy-btn svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* --------------------------------------------------------------------------
   HTMX Loading States (enhanced)
   -------------------------------------------------------------------------- */

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

.htmx-settling {
    opacity: 0.85;
}

.htmx-swapping {
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

/* Spinner animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

/* --------------------------------------------------------------------------
   Translation Page
   -------------------------------------------------------------------------- */

.translation-result {
    background: rgba(6, 182, 212, 0.05);
    border: 1px solid rgba(6, 182, 212, 0.15);
    border-radius: 0.5rem;
    padding: 1rem;
}

.glossary-term {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    margin: 0.125rem;
}

/* --------------------------------------------------------------------------
   Utility Helpers
   -------------------------------------------------------------------------- */

.text-mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    color: #4b5563;
}

/* Card section divider */
.card-divider {
    border-top: 1px solid var(--glass-border);
}
