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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #334155;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 1.5rem;
    color: #fbbf24;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    height: calc(100vh - 140px);
    gap: 0;
}

/* Sidebar */
.sidebar {
    background: white;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1e293b;
}

.search-container {
    position: relative;
}

.search-container input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.2s ease;
}

.search-container input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-container i {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
}

/* Component Categories */
.component-categories {
    padding: 1rem;
}

.category {
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: white;
}

.category-header {
    padding: 0.75rem 1rem;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.category-header:hover {
    background: #f1f5f9;
}

.category-header i:first-child {
    color: #3b82f6;
}

.toggle-icon {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.category.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.category-content {
    padding: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.category.collapsed .category-content {
    max-height: 0;
    padding: 0 0.5rem;
    overflow: hidden;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    cursor: grab;
    transition: all 0.2s ease;
    background: white;
    font-size: 0.875rem;
}

.component-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.component-item:active {
    cursor: grabbing;
}

.component-item.threat-item {
    border-color: #f59e0b;
    background: #fffbeb;
}

.component-item.threat-item:hover {
    border-color: #d97706;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.component-item.mitigation-item {
    border-color: #10b981;
    background: #ecfdf5;
}

.component-item.mitigation-item:hover {
    border-color: #059669;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.component-item i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
}

.add-custom-btn {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #d1d5db;
    border-radius: 0.375rem;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.add-custom-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #f8fafc;
}

/* Canvas Area */
.canvas-area {
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    position: relative;
}

.canvas-header {
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-info h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.project-info span {
    font-size: 0.875rem;
    color: #6b7280;
}

.canvas-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    background: white;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    transition: all 0.2s ease;
}

.control-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #f8fafc;
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.canvas {
    width: 100%;
    height: 100%;
    cursor: default;
    background: white;
}

/* Canvas Components */
.canvas-component {
    cursor: move;
    user-select: none;
}

.canvas-component rect {
    fill: white;
    stroke: #3b82f6;
    stroke-width: 2;
    rx: 8;
    transition: all 0.2s ease;
}

.canvas-component.threat rect {
    fill: #fffbeb;
    stroke: #f59e0b;
}

.canvas-component.mitigation rect {
    fill: #ecfdf5;
    stroke: #10b981;
}

.canvas-component.selected rect {
    stroke-width: 3;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.canvas-component:hover rect {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.canvas-component text {
    fill: #1e293b;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* Connection Lines */
.connection-line {
    stroke: #6b7280;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
}

.connection-line.threat-connection {
    stroke: #f59e0b;
    stroke-dasharray: 5,5;
}

.connection-line.mitigation-connection {
    stroke: #10b981;
}

/* Properties Panel */
.properties-panel {
    background: white;
    border-left: 1px solid #e2e8f0;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05);
}

.properties-panel.open {
    transform: translateX(0);
}

.properties-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.properties-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

.close-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: #374151;
}

.properties-content {
    padding: 1.5rem;
}

.no-selection {
    color: #6b7280;
    text-align: center;
    font-style: italic;
}

.property-group {
    margin-bottom: 1.5rem;
}

.property-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.property-group input,
.property-group textarea,
.property-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.property-group input:focus,
.property-group textarea:focus,
.property-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Analysis Panel */
.analysis-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    max-height: 50vh;
}

.analysis-panel.open {
    transform: translateY(0);
}

.analysis-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analysis-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

.analysis-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.analysis-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

.analysis-btn:hover {
    background: #2563eb;
}

.analysis-content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(50vh - 80px);
}

.analysis-placeholder {
    text-align: center;
    color: #6b7280;
    padding: 2rem;
}

.analysis-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #d1d5db;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: white;
    color: #6b7280;
    border: 1px solid #d1d5db;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Footer */
.footer {
    background: #1e293b;
    color: #94a3b8;
    padding: 1rem 0;
    border-top: 1px solid #334155;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: #e2e8f0;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 280px 1fr 320px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .sidebar {
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .properties-panel {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 350px;
        z-index: 1500;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .canvas-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .properties-panel {
        width: 100%;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Drag and Drop States */
.drag-over {
    background: rgba(59, 130, 246, 0.1);
    border: 2px dashed #3b82f6;
}

.dragging {
    opacity: 0.5;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    pointer-events: none;
    opacity: 0.6;
}

.error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.success {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

