/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --light: #f3f4f6;
    --dark: #1f2937;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f9fafb;
    color: #374151;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    box-shadow: 0 2px 10px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 65px;
}

.nav-brand a {
    font-size: 1.4em;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 5px;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    display: block;
    border-radius: 6px;
    transition: background 0.3s;
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    min-width: 230px;
    padding: 6px 0;
    z-index: 1001;
    list-style: none;
}

/* JS-controlled open state — NOT :hover */
.dropdown-menu.dropdown-open {
    display: block;
}

.dropdown-menu li {
    border-bottom: 1px solid var(--border);
    list-style: none;
}

.dropdown-menu li:last-child {
    border-bottom: none;
}

.dropdown-menu a {
    color: var(--dark);
    padding: 12px 20px;
    display: block;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.dropdown-menu a:hover {
    background: var(--light);
}

/* Right-aligned dropdown (profile menu) */
.dropdown-menu-right {
    left: auto;
    right: 0;
}

.logout-link {
    color: var(--danger) !important;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-user span {
    font-weight: 500;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2.5em;
    color: var(--dark);
    margin-bottom: 10px;
}

.page-header p {
    color: #6b7280;
    font-size: 1.1em;
}

.header-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 30px;
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease-out;
}

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

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.alert-close:hover {
    opacity: 1;
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    color: var(--dark);
    margin-bottom: 10px;
}

.auth-header p {
    color: #6b7280;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-footer {
    margin-top: 30px;
    text-align: center;
}

.security-note {
    font-size: 0.9em;
    color: #6b7280;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

small {
    display: block;
    margin-top: 5px;
    color: #6b7280;
    font-size: 0.85em;
}

.checkbox-label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9em;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px var(--shadow);
}

.stat-icon {
    font-size: 2.5em;
}

.stat-content h3 {
    font-size: 2em;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-content p {
    color: #6b7280;
    font-size: 0.9em;
}

/* Quick Actions */
.quick-actions {
    margin-bottom: 40px;
}

.quick-actions h2 {
    margin-bottom: 20px;
    color: var(--dark);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.action-card {
    background: white;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
}

.action-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px var(--shadow);
}

.action-icon {
    font-size: 3em;
    display: block;
    margin-bottom: 15px;
}

.action-card h3 {
    color: var(--dark);
    margin-bottom: 10px;
}

.action-card p {
    color: #6b7280;
    font-size: 0.9em;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--light);
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table code {
    background: var(--light);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.badge-secondary {
    background: #6b7280;
    color: white;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-danger {
    background: var(--danger);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: white;
}

.badge-info {
    background: var(--info);
    color: white;
}

/* Detail Card */
.detail-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px var(--shadow);
}

.part-number-display {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    margin-bottom: 30px;
    letter-spacing: 2px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.detail-section {
    padding: 20px;
    background: var(--light);
    border-radius: 8px;
}

.detail-section h3 {
    color: var(--dark);
    margin-bottom: 15px;
    font-size: 1.2em;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.detail-label {
    font-weight: 600;
    color: #6b7280;
}

.detail-value {
    color: var(--dark);
    font-weight: 500;
}

.full-width {
    grid-column: 1 / -1;
}

.sharepoint-section {
    background: #fef3c7;
}

.sharepoint-path {
    padding: 15px;
    background: white;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    color: var(--dark);
}

.metadata-section {
    background: var(--light);
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.metadata-label {
    font-size: 0.85em;
    color: #6b7280;
    font-weight: 600;
}

.metadata-value {
    color: var(--dark);
}

/* Filter Section */
.filter-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 30px;
}

.filter-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.page-link {
    padding: 10px 15px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--dark);
    background: white;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.page-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
}

.empty-state p {
    font-size: 1.2em;
    color: #6b7280;
    margin-bottom: 20px;
}

/* Help Box */
.help-box {
    background: #dbeafe;
    border-left: 4px solid var(--info);
    padding: 20px;
    border-radius: 8px;
    margin-top: 30px;
}

.help-box h3 {
    color: var(--dark);
    margin-bottom: 15px;
}

.help-box ul {
    margin-left: 20px;
    margin-top: 10px;
}

.help-box li {
    margin-bottom: 8px;
}

.help-box .note {
    margin-top: 15px;
    font-style: italic;
}

/* Result/Breakdown */
.result-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-top: 30px;
}

.breakdown-grid {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

.breakdown-item {
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breakdown-label {
    font-weight: 600;
    color: #6b7280;
}

.breakdown-value {
    color: var(--primary);
    font-weight: 600;
}

.sharepoint-box {
    padding: 20px;
    background: #fef3c7;
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    margin-top: 20px;
}

.result-actions {
    margin-top: 20px;
    text-align: center;
}

/* Admin Stats */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-item strong {
    display: block;
    font-size: 2em;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-item span {
    color: #6b7280;
    font-size: 0.9em;
}

/* Error Pages */
.error-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-content {
    text-align: center;
    padding: 40px;
}

.error-content h1 {
    font-size: 6em;
    color: var(--primary);
    margin-bottom: 20px;
}

.error-content h2 {
    font-size: 2em;
    color: var(--dark);
    margin-bottom: 15px;
}

.error-content p {
    color: #6b7280;
    margin-bottom: 30px;
}

.error-note {
    font-size: 0.9em;
    font-style: italic;
}

/* Footer */
.footer {
    background: var(--dark);
    color: white;
    padding: 30px 20px;
    text-align: center;
    margin-top: auto;
}

.footer-content p {
    margin: 5px 0;
}

.footer-note {
    font-size: 0.9em;
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 15px;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
    }

    .nav-user {
        margin-top: 15px;
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .stats-grid,
    .action-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .page-header h1 {
        font-size: 2em;
    }
}

/* Utilities */
.text-muted {
    color: #6b7280;
}

.link {
    color: var(--primary);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

/* Nav User Dropdown Trigger */
.nav-user-trigger {
    color: white !important;
    cursor: pointer;
}

.nav-dropdown-trigger {
    cursor: pointer;
}

/* Notification Badge in Nav */
.nav-notification-link {
    position: relative;
}

.nav-notification-badge {
    display: none;
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 0.65em;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 18px;
    text-align: center;
}

/* Profile Page */
.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    align-items: start;
}

.profile-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px var(--shadow);
    text-align: center;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 15px;
    border: 4px solid var(--primary);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    font-weight: bold;
}

.profile-name {
    font-size: 1.4em;
    color: var(--dark);
    margin-bottom: 8px;
}

.profile-role {
    margin-bottom: 8px;
}

.profile-dept, .profile-title-text {
    color: #6b7280;
    font-size: 0.9em;
    margin-bottom: 4px;
}

.profile-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.profile-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.profile-info-item {
    display: flex;
    flex-direction: column;
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.profile-info-item:nth-child(odd) {
    border-right: 1px solid var(--border);
}

.profile-info-label {
    font-size: 0.8em;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.profile-info-value {
    color: var(--dark);
    font-weight: 500;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.profile-stat-item {
    text-align: center;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
}

.profile-stat-number {
    display: block;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.profile-stat-label {
    font-size: 0.8em;
    color: #6b7280;
}

/* Notifications Page */
.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification-item {
    display: flex;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
    transition: all 0.3s;
}

.notification-item:hover {
    box-shadow: 0 4px 16px var(--shadow);
}

.notification-unread {
    background: #f0f4ff;
    border-left: 4px solid var(--primary);
}

.notification-priority-urgent {
    border-left-color: var(--danger) !important;
}

.notification-priority-high {
    border-left-color: var(--warning) !important;
}

.notification-indicator {
    display: flex;
    align-items: flex-start;
    padding: 20px 0 20px 15px;
}

.unread-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 6px;
}

.notification-content {
    flex: 1;
    padding: 18px 20px;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
}

.notification-header h3 {
    font-size: 1.05em;
    color: var(--dark);
    margin: 0;
}

.notification-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.notification-time {
    font-size: 0.8em;
    color: #6b7280;
    white-space: nowrap;
}

.notification-message {
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 10px;
}

.notification-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-mark-read {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--border);
}

.btn-mark-read:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Responsive Profile & Notifications */
@media (max-width: 768px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .profile-info-grid {
        grid-template-columns: 1fr;
    }

    .profile-info-item:nth-child(odd) {
        border-right: none;
    }

    .notification-header {
        flex-direction: column;
    }

    .notification-meta {
        margin-top: 5px;
    }
}
