:root {
    --primary-color: #003366;
    --primary-light: #0055AA;
    --primary-lighter: #e7f3ff;
    --text-color: #333333;
    --text-muted: #6c757d;
    --bg-color: #FFFFFF;
    --bg-light: #f8f9fa;
    --bg-lighter: #fafbfc;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --border-color: #e0e4e7;
    --border-light: #f0f0f0;
    --sidebar-width: 240px;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-light);
    line-height: 1.6;
    font-size: 14px;
}

/* Header */
.navbar {
    background-color: var(--primary-color);
    padding: 0.875rem 1.5rem;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-brand {
    display: flex;
    align-items: center;
    color: white !important;
    font-weight: 600;
    font-size: 1.25rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.navbar-brand:hover {
    opacity: 0.9;
}

.navbar-brand img {
    height: 38px;
    margin-right: 12px;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
    border-radius: 6px;
    margin: 0 0.25rem;
}

.navbar-nav .nav-link:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-nav .nav-link.active {
    color: white !important;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Main Container */
.main-container {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-lighter);
    border-right: 1px solid var(--border-color);
    padding: 1.25rem 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
}

.sidebar-menu li {
    margin: 0.125rem 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-weight: 500;
    font-size: 0.9rem;
}

.sidebar-menu a i {
    width: 20px;
    text-align: center;
    opacity: 0.7;
}

.sidebar-menu a:hover {
    background-color: var(--primary-lighter);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.sidebar-menu a:hover i {
    opacity: 1;
}

.sidebar-menu a.active {
    background-color: var(--primary-lighter);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-menu a.active i {
    opacity: 1;
}

.sidebar-menu .menu-section {
    padding: 0.75rem 1.25rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-top: 0.75rem;
}

.sidebar-menu .menu-section:first-child {
    margin-top: 0;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    background-color: var(--bg-light);
    min-height: calc(100vh - 60px);
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border-light);
    border-left: 4px solid var(--primary-color);
    color: var(--text-color);
    padding: 1.125rem 1.5rem;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.6rem 1.25rem;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn i {
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 51, 102, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 51, 102, 0.3);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.btn-success:hover {
    background-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.btn-warning {
    background-color: var(--warning-color);
    color: #333;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
}

.btn-warning:hover {
    background-color: #e0a800;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.btn-info {
    background-color: var(--primary-light);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 85, 170, 0.2);
}

.btn-info:hover {
    background-color: #004488;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 85, 170, 0.3);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn-outline-primary {
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Tables */
.table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0;
}

.table thead {
    background-color: var(--bg-lighter);
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
}

.table thead th {
    border: none;
    padding: 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: var(--bg-lighter);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Forms */
.form-label {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
    outline: none;
}

/* Alerts */
.alert {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: none;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-left-color: var(--success-color);
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: var(--error-color);
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: var(--warning-color);
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left-color: var(--primary-light);
}

/* Workflow Stages Timeline */
.stages-timeline {
    padding: 1rem 0 2rem;
}

.timeline-track {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
}

.timeline-node {
    flex: 0 0 auto;
    text-align: center;
    position: relative;
    z-index: 2;
}

.timeline-node .node-link {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 0.5rem;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.timeline-node .node-link:hover {
    background-color: var(--bg-lighter);
    transform: translateY(-2px);
}

.timeline-node .node-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-lighter);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
    position: relative;
}

.timeline-node.active .node-circle {
    background: var(--stage-color, var(--primary-color));
    border-color: var(--stage-color, var(--primary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.timeline-node .node-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.timeline-node .node-number {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.timeline-node .node-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.timeline-node .node-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--bg-lighter);
    color: var(--text-muted);
    margin: 0.25rem auto 0;
}

.timeline-node .node-count.has-items {
    background: var(--stage-color, var(--primary-color));
    color: white;
}

.timeline-connector {
    flex: 1;
    height: 3px;
    background: var(--border-color);
    margin: 28px 0.5rem 0;
    border-radius: 2px;
    position: relative;
}

.timeline-connector.active {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

/* Stages Accordion */
.stages-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stage-panel {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: all 0.3s ease;
}

.stage-panel:hover {
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

.stage-panel.expanded {
    box-shadow: var(--shadow-md);
}

.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.stage-header:hover {
    background-color: var(--bg-lighter);
}

.stage-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stage-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stage-info h6 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

.stage-info .stage-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
    display: block;
}

.stage-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--bg-lighter);
    color: var(--text-muted);
    padding: 0 0.5rem;
}

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

.stage-chevron {
    color: var(--text-muted);
    transition: transform 0.3s ease;
    font-size: 0.9rem;
}

.stage-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-top: 1px solid transparent;
}

.stage-panel.expanded .stage-content {
    border-top-color: var(--border-light);
}

.stage-items {
    padding: 0.5rem 0;
}

.stage-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

.stage-item:hover {
    background-color: var(--bg-lighter);
}

.stage-item .item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}

.stage-item .item-details {
    flex: 1;
    min-width: 0;
}

.stage-item .item-title {
    display: block;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-item .item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.stage-item .item-arrow {
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.stage-item:hover .item-arrow {
    opacity: 1;
    transform: translateX(3px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.status-responded,
.status-dot.status-approved {
    background-color: #27ae60;
}

.status-dot.status-sent,
.status-dot.status-draft {
    background-color: #f39c12;
}

.status-dot.status-pending {
    background-color: #95a5a6;
}

.stage-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
    color: var(--text-muted);
}

.stage-empty i {
    font-size: 2rem;
    opacity: 0.5;
}

.stage-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    background: var(--bg-lighter);
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-top: 1px solid var(--border-light);
}

.stage-action:hover {
    background: var(--primary-lighter);
    color: var(--primary-color);
}

.stage-action i {
    transition: transform 0.2s ease;
}

.stage-action:hover i {
    transform: translateX(3px);
}

/* Legacy Workflow Stages (keep for compatibility) */
.workflow-stages {
    display: flex;
    justify-content: space-between;
    margin: 2rem 0;
    position: relative;
    gap: 1rem;
}

.workflow-stages::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, var(--primary-color), var(--border-color));
    z-index: 0;
}

.workflow-stage {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 1;
}

.stage-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: white;
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.workflow-stage.active .stage-circle {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 8px rgba(0, 51, 102, 0.3);
    transform: scale(1.1);
}

.workflow-stage.completed .stage-circle {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.stage-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.workflow-stage.active .stage-label,
.workflow-stage.completed .stage-label {
    color: var(--primary-color);
    font-weight: 600;
}

/* Badges */
.badge {
    padding: 0.4em 0.7em;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

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

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

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

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

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

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    background-color: var(--bg-lighter);
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-lighter);
}

.file-upload-area.dragover {
    border-color: var(--primary-color);
    background-color: var(--primary-lighter);
    transform: scale(1.02);
}

/* Loading Spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
    border-color: var(--primary-color);
    border-right-color: transparent;
}

/* Pagination */
.pagination {
    margin-top: 1.5rem;
}

.page-link {
    color: var(--primary-color);
    border-color: var(--border-color);
    border-radius: 6px;
    margin: 0 0.25rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
}

.page-link:hover {
    color: var(--primary-light);
    background-color: var(--bg-lighter);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Responsive */
@media (max-width: 992px) {
    .timeline-track {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .timeline-connector {
        display: none;
    }
    
    .timeline-node {
        flex: 0 0 calc(33.333% - 0.5rem);
    }
    
    .timeline-node .node-circle {
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }
    
    .timeline-node .node-name {
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .content-area {
        padding: 1rem;
    }
    
    .workflow-stages {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .workflow-stages::before {
        display: none;
    }
    
    .card {
        border-radius: 8px;
    }
    
    .timeline-node {
        flex: 0 0 calc(50% - 0.5rem);
    }
    
    .stage-header {
        padding: 0.875rem 1rem;
    }
    
    .stage-header-left {
        gap: 0.75rem;
    }
    
    .stage-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .stage-info h6 {
        font-size: 0.875rem;
    }
    
    .stage-info .stage-desc {
        display: none;
    }
    
    .stage-item {
        padding: 0.625rem 1rem;
    }
    
    .stage-item .item-icon {
        width: 32px;
        height: 32px;
    }
}

/* Utilities */
.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.me-2 { margin-right: 0.5rem; }

/* Custom scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Smooth transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}
