:root {
    --primary-color: #6366f1;
    --secondary-color: #06b6d4;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    position: relative;
    z-index: 0;
}

.brand-color {
    color: var(--primary-color);
}

.navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Center the logo in forms */
.text-center .navbar-brand {
    justify-content: center;
    margin: 0 auto;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
    flex-shrink: 0;
    display: block;
    vertical-align: middle;
}

.main-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin: 2rem auto;
    padding: 2rem;
    max-width: 1400px;
    position: relative;
    z-index: 1;
}

.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.btn-primary:hover {
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.system-tile {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border-left: 5px solid var(--primary-color);
    min-height: 132px;
    display: flex;
    flex-direction: column;
}

.system-tile .text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    max-width: 100%;
}

.system-tile > div {
    overflow: hidden;
    width: 100%;
}

.system-tile p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.system-tile .text-muted {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.system-tile:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.filter-panel {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.form-control, .form-select {
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    padding: 0.75rem;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

.badge {
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-weight: 500;
}

.view-toggle {
    background: white;
    border-radius: 10px;
    padding: 0.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem;
}

.view-toggle .btn {
    border-radius: 6px;
    margin: 0;
    flex: 0 0 auto;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    height: 38px; /* Match form control height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .filter-panel .row {
        flex-direction: column;
    }
    
    .filter-panel .col-12 {
        margin-bottom: 1rem;
    }
    
    .view-toggle {
        justify-content: center;
        width: 100%;
    }
    
    .form-select {
        min-width: 100% !important;
    }
}

@media (max-width: 576px) {
    .view-toggle {
        flex-direction: column;
        align-items: stretch;
    }
    
    .view-toggle .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
}

.color-legend {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.color-legend h5 {
    margin-bottom: 0.75rem;
    color: var(--dark-color);
    font-size: 0.9rem;
}

.legend-items {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Import CSV Modal Tab Styles */
.nav-tabs .nav-link.disabled {
    color: #6c757d;
    pointer-events: none;
    background-color: transparent;
    border-color: transparent;
}

.nav-tabs .nav-link.disabled:hover {
    color: #6c757d;
    background-color: transparent;
    border-color: transparent;
}

.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.domain-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.domain-group {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.architecture-view {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.architecture-domain {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.architecture-domain h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.architecture-subdomains {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.architecture-subdomain {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 1.5rem;
    border-left: 4px solid var(--secondary-color);
}

.architecture-subdomain h4 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.architecture-systems {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.architecture-system {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 4px solid transparent;
    min-height: 80px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.architecture-system .text-muted {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#gridView {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.col-md-6, .col-lg-4 {
    max-width: 100%;
}

/* Project Cards - Consistent Sizing and Text Truncation */
.card.h-100 {
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.card.h-100 .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card.h-100 .card-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    flex-shrink: 1;
}

.card.h-100 .card-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.architecture-system:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.domain-system {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 4px solid transparent;
    min-height: 80px;
    display: flex;
    align-items: center;
    overflow: hidden;
    margin-bottom: 1rem;
}

.domain-system .text-muted {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.domain-system:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.color-legend {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.color-legend h5 {
    margin-bottom: 0.75rem;
    color: var(--dark-color);
}

.legend-items {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.loading {
    display: none;
    text-align: center;
    padding: 2rem;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Timeline View Styles */
.timeline-view {
    padding: 2rem 0;
}

.timeline-container {
    max-width: 1200px;
    margin: 0 auto;
}

.timeline-year {
    margin-bottom: 3rem;
}

.timeline-year-header {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.timeline-items {
    position: relative;
    padding-left: 2rem;
}

.timeline-items::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--primary-color), #e9ecef);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
    cursor: pointer;
}

.timeline-marker {
    position: absolute;
    left: -1.5rem;
    top: 0.5rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timeline-content {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.timeline-content:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.timeline-date {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.timeline-title {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.timeline-description {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Relationships View Styles */
.relationships-container {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.relationships-header {
    display: flex;
    justify-content: between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.relationships-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.relationship-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.relationship-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    cursor: pointer;
}

.relationship-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.relationship-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.relationship-type {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.relationship-systems {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.relationship-arrow {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.system-node {
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 120px;
    text-align: center;
}

.relationship-description {
    color: #6c757d;
    font-size: 0.9rem;
    font-style: italic;
}

.relationship-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.relationship-actions .btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

.no-relationships {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.no-relationships i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Relationship Type Colors */
.relationship-type.integrates_with { background: #28a745; }
.relationship-type.sends_data_to { background: #17a2b8; }
.relationship-type.calls { background: #fd7e14; }
.relationship-type.is_part_of { background: #6c757d; }

/* Relationship Diagram Styles */
.relationships-diagram {
    margin-top: 2rem;
    position: relative;
    overflow: hidden;
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.diagram-container {
    background: white;
    overflow: auto;
    min-height: 700px; /* Increased from 600px */
    max-height: 85vh;  /* Increased from 80vh */
    position: relative;
}

#diagramSVG {
    width: 100%;
    height: 100%;
    min-height: 700px; /* Increased from 600px */
    cursor: grab;
}

#diagramSVG:active {
    cursor: grabbing;
}

#diagramSVG text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

#diagramSVG circle {
    transition: all 0.2s ease;
}

#diagramSVG circle:hover {
    stroke-width: 5;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

#diagramSVG line {
    transition: all 0.2s ease;
}

#diagramSVG line:hover {
    stroke-width: 5;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#diagramSVG text:hover {
    font-weight: bold;
}

/* Fix dropdown menu z-index issues */
.dropdown-menu {
    z-index: 1050 !important;
    position: absolute !important;
}

.navbar .dropdown-menu {
    z-index: 1051 !important;
}

/* More specific navbar dropdown fixes */
.navbar-nav .dropdown-menu {
    z-index: 9999 !important;
    position: absolute !important;
}

.navbar .nav-item .dropdown-menu {
    z-index: 9999 !important;
    position: absolute !important;
}

/* Ensure navbar itself has proper z-index */
.navbar {
    z-index: 1030 !important;
    position: relative !important;
}

/* Force user dropdown to appear above everything */
.navbar .dropdown-menu {
    z-index: 99999 !important;
    position: absolute !important;
    transform: none !important;
}

/* Override any Bootstrap dropdown positioning */
.dropdown-menu.show {
    z-index: 99999 !important;
    position: absolute !important;
}

/* Ensure modals appear above everything */
.modal {
    z-index: 1060 !important;
}

.modal-backdrop {
    z-index: 1055 !important;
}

/* Ensure tooltips and popovers appear above dropdowns */
.tooltip {
    z-index: 1070 !important;
}

.popover {
    z-index: 1065 !important;
}