/* ========================================================
   SHARED STYLES - AI Inventory Min/Max Optimizer
   Common variables, layout, components across all pages
   ======================================================== */

/* --- CSS Variables (matching existing theme) --- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #0ea5e9;
    --accent: #e11d48;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --dark: #1e293b;
    --card-bg: #ffffff;
    --glass: rgba(248, 250, 252, 0.85);
    --text-primary: #1e293b;
    --text-secondary: #4a5568;
    --text-muted: #6b7a8d;
    --border-color: #e8ecf1;
    --bg-page: #fbfcfd;
    --bg-subtle: #f5f7fa;
    --sidebar-bg: #1e2a3a;
    --navbar-height: 60px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Top Navbar --- */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.nav-brand:hover { text-decoration: none; }

.nav-brand img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.nav-links a {
    color: rgba(255,255,255,0.75);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.nav-links a:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
    text-decoration: none;
}

.nav-links a.active {
    color: #fff;
    background: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.nav-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.nav-user-name {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
}

.nav-logout-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.nav-logout-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* --- Page Container --- */
.page-container {
    margin-top: var(--navbar-height);
    padding: 2rem 2rem 4rem;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover { text-decoration: none; opacity: 0.9; transform: translateY(-1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-secondary { background: var(--bg-subtle); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* --- Grid layouts --- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

/* --- Status badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #1d4ed8; }

/* --- Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-subtle);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:hover { background: var(--bg-subtle); }

/* --- Footer --- */
.page-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

.page-footer a { color: var(--primary); }

/* --- Accordion (FAQ) --- */
.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.accordion-header {
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    transition: background 0.2s;
}

.accordion-header:hover { background: var(--bg-subtle); }

.accordion-header .arrow {
    transition: transform 0.3s;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.accordion-item.open .accordion-header .arrow { transform: rotate(180deg); }

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1.25rem;
}

.accordion-item.open .accordion-body {
    max-height: 1000px;
    padding: 0 1.25rem 1.25rem;
}

/* --- Card Accent (animated gradient top border) --- */
.card-accent {
    position: relative;
    overflow: hidden;
}

.card-accent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--primary));
    background-size: 200% 100%;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* --- Animate In (fadeInUp with staggered delays) --- */
.animate-in {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }
.animate-in:nth-child(7) { animation-delay: 0.35s; }
.animate-in:nth-child(8) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}

/* --- Stat Card Enhanced (left colored border accent) --- */
.stat-card-enhanced {
    border-left: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-card-enhanced.green { border-left-color: var(--success); }
.stat-card-enhanced.amber { border-left-color: var(--warning); }
.stat-card-enhanced.red { border-left-color: var(--danger); }
.stat-card-enhanced.blue { border-left-color: var(--primary); }
.stat-card-enhanced.purple { border-left-color: #7c3aed; }

/* --- Status Dot Pulse --- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot.green { background: #16a34a; }
.status-dot.red { background: #dc2626; }
.status-dot.yellow { background: #d97706; }

.status-dot.pulse {
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; }
    50% { box-shadow: 0 0 0 4px transparent; }
}

.status-dot.green.pulse { color: rgba(22,163,74,0.4); }
.status-dot.red.pulse { color: rgba(220,38,38,0.4); }
.status-dot.yellow.pulse { color: rgba(217,119,6,0.4); }

/* --- Form Input / Label (improved form styling) --- */
.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --- Toast Notification --- */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.toast-notification.show { transform: translateY(0); opacity: 1; }
.toast-notification.success { background: var(--success); }
.toast-notification.error { background: var(--danger); }
.toast-notification.info { background: var(--primary); }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.6;
}

/* --- Steps List (numbered circular badges) --- */
.steps-list {
    list-style: none;
    counter-reset: step-counter;
    padding: 0;
}

.steps-list li {
    counter-increment: step-counter;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.steps-list li::before {
    content: counter(step-counter);
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 0.1rem;
}

/* --- Role badges (shared) --- */
.badge-root { background: #fef3c7; color: #92400e; }
.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-user { background: #e2e8f0; color: #475569; }

/* --- Collapsible Toggle --- */
.collapsible-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    border: none;
    background: none;
    transition: opacity 0.2s;
}

.collapsible-toggle:hover { opacity: 0.8; }

.collapsible-toggle .arrow {
    transition: transform 0.3s;
    font-size: 0.7rem;
}

.collapsible-toggle.open .arrow { transform: rotate(180deg); }

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.collapsible-content.open {
    max-height: 500px;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .page-container { padding: 1.5rem; }
}

@media (max-width: 768px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .nav-links { display: none; }
    .nav-hamburger { display: block; }
    .page-container { padding: 1rem; }
    .top-navbar { padding: 0 1rem; }
}

@media (max-width: 480px) {
    .page-container { padding: 0.75rem; }
    .card { padding: 1rem; }
    .nav-user-name { display: none; }
}

/* --- Hamburger (mobile) --- */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.mobile-nav {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--sidebar-bg);
    z-index: 999;
    flex-direction: column;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
}

.mobile-nav.open { display: flex; }

.mobile-nav a {
    color: rgba(255,255,255,0.85);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-decoration: none;
}

.mobile-nav a:hover, .mobile-nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
