/* CloudMapper Clean CSS - Consolidated Version */

:root {
    --primary-color: #F7931E;
    --primary-hover: #FF6B35;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    /* Dark Theme Colors (default) */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #161b22;
    --bg-hover: #30363d;
    
    --text-primary: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --text-accent: #58a6ff;
    
    --border-color: #30363d;
    --border-hover: #424a53;
    
    --sidebar-width: 280px;
    --header-height: 70px;
    --footer-height: 32px;
    
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

/* Light Mode Variables */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-accent: #3b82f6;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout Structure */
.app-layout {
    display: flex;
    flex: 1;
    width: 100%;
    height: calc(100vh - var(--header-height) - var(--footer-height));
}

.app-layout.full-width .main-content {
    width: 100%;
    margin-left: 0;
}

.app-layout.full-width .sidebar {
    display: none;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, #2d3748, #1a202c);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1050;
    display: flex;
    align-items: center;
    padding: 0;
}

.app-header .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 2rem;
    height: 100%;
}

.app-header .header-left {
    display: flex;
    align-items: center;
}

.app-header .header-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.app-header .header-logo {
    height: 24px;
    width: auto;
    vertical-align: middle;
}

.app-footer .footer-logo {
    height: 20px;
    width: auto;
    vertical-align: middle;
}

.app-header .header-right {
    display: flex;
    align-items: center;
}

/* Mobile menu button - hidden by default */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 0.5rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

/* Header Dropdown */
.header-dropdown-toggle {
    background: none !important;
    border: none !important;
    color: rgba(255,255,255,0.9) !important;
    padding: 0.5rem 1rem !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    box-shadow: none !important;
}

.header-dropdown-toggle:hover,
.header-dropdown-toggle:focus {
    background-color: rgba(255,255,255,0.1) !important;
    color: white !important;
    box-shadow: none !important;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* VPC Controls */
.vpc-controls {
    margin-bottom: 1rem;
}

.vpc-controls .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* VPC Selector */
.vpc-selector-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.vpc-list-container-full {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.vpc-selector-sidebar {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.5rem 1rem 0.5rem;
}

.vpc-item {
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.vpc-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

.vpc-item.selected {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.vpc-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.vpc-id {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.vpc-cidr {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
    margin-left: var(--sidebar-width);
    min-height: 0;
}

.content-area {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Network Diagram */
.full-diagram-container {
    width: 100%;
    height: calc(100vh - var(--header-height) - var(--footer-height));
    background: transparent;
    overflow: auto;
    padding: 0;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2rem;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    opacity: 0.5;
}

/* Mermaid Diagram Styling */
#diagram-container .mermaid {
    width: 100% !important;
    height: auto !important;
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
}

#diagram-container .mermaid svg {
    max-width: none !important;
    width: auto !important;
    height: auto !important;
    min-width: 100%;
    min-height: 100%;
    transform-origin: top left;
    transition: none !important; /* Prevent flickering during initial setup */
}

#diagram-container .mermaid .node rect,
#diagram-container .mermaid .node circle,
#diagram-container .mermaid .node ellipse,
#diagram-container .mermaid .node polygon {
    fill: var(--bg-secondary) !important;
    stroke: var(--border-color) !important;
    stroke-width: 2px !important;
}

#diagram-container .mermaid .edgePath .path {
    stroke: var(--text-muted) !important;
    stroke-width: 2px !important;
}

#diagram-container .mermaid .edgeLabel {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Internet node styling - make it bigger and more prominent */
#diagram-container .mermaid .node#internet rect,
#diagram-container .mermaid .node#internet circle,
#diagram-container .mermaid .node#internet ellipse,
#diagram-container .mermaid .node#internet polygon {
    fill: #e3f2fd !important;
    stroke: #1976d2 !important;
    stroke-width: 4px !important;
    transform: scale(1.3) !important;
    transform-origin: center !important;
}

#diagram-container .mermaid .node#internet .label {
    font-size: 18px !important;
    font-weight: 600 !important;
    fill: #000 !important;
}

/* Print Styles */
@media print {
    /* Hide all UI elements - show only diagram */
    .app-header,
    .app-footer,
    .sidebar,
    .diagram-controls,
    .sidebar-overlay,
    .btn,
    .alert,
    .footer-brand,
    .footer-copyright,
    .footer-support-link {
        display: none !important;
    }
    
    /* Make content fill entire page for single-page printing */
    html, body {
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
    
    .app-layout,
    .main-content,
    .content-area,
    #diagram-container {
        width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 100vh !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Optimize diagram for single-page printing */
    #diagram-container .mermaid {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 100vh !important;
    }
    
    #diagram-container .mermaid svg {
        width: 95% !important;
        height: 95% !important;
        max-width: 95% !important;
        max-height: 95% !important;
        min-width: 90% !important;
        min-height: 90% !important;
        transform: none !important;
        transform-origin: initial !important;
        page-break-inside: avoid !important;
    }
    
    /* Ensure text is visible in print */
    * {
        color: #000 !important;
        background: transparent !important;
    }
    
    /* Force light theme for printing */
    [data-theme="dark"] * {
        color: #000 !important;
        background: transparent !important;
    }
    
    /* Make sure diagram elements are visible */
    .mermaid text {
        fill: #000 !important;
    }
    
    .mermaid rect,
    .mermaid circle,
    .mermaid ellipse,
    .mermaid polygon {
        stroke: #333 !important;
        stroke-width: 1px !important;
    }
    
    /* Adaptive page setup for optimal fit */
    @page {
        size: A3 landscape;
        margin: 0.2in;
    }
    
    /* Try A2 for very large diagrams */
    @media (min-width: 2000px) {
        @page {
            size: A2 landscape;
            margin: 0.2in;
        }
    }
    
    body {
        font-size: 10pt;
        line-height: 1.2;
    }
}

/* Footer */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    z-index: 1040;
    display: flex;
    align-items: center;
    padding: 0;
}

.app-footer .footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 2rem;
    height: 100%;
}

.app-footer .footer-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-footer .footer-brand {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.app-footer .footer-copyright {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.app-footer .footer-right {
    display: flex;
    align-items: center;
}

.app-footer .footer-support-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.app-footer .footer-support-link:hover {
    color: var(--primary-color);
}

/* Bootstrap Dark Mode Overrides */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: white !important;
}

.btn-secondary {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: var(--bg-hover) !important;
    border-color: var(--border-hover) !important;
    color: var(--text-primary) !important;
}

.card {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.card-header {
    background-color: var(--bg-tertiary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

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

.table th {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

.table td {
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.table-hover tbody tr:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.modal-content {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.modal-header {
    background-color: var(--bg-tertiary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.modal-body {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

.alert-info {
    background-color: rgba(6, 182, 212, 0.1) !important;
    border-color: var(--info-color) !important;
    color: var(--info-color) !important;
}

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

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

.text-muted {
    color: var(--text-muted) !important;
}

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

.text-success {
    color: var(--success-color) !important;
}

.form-control {
    background-color: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.form-control:focus {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--primary-color) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
}

.dropdown-menu {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.dropdown-item {
    color: var(--text-primary) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Light Mode Header Override */
[data-theme="light"] .app-header {
    background: linear-gradient(135deg, #2d3748, #1a202c) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
        --header-height: 60px;
        --footer-height: 50px;
    }
    
    .app-layout {
        flex-direction: column;
    }
    
    /* Mobile: Hide sidebar by default, show as overlay when needed */
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: -100%;
        width: 80vw;
        max-width: 320px;
        height: calc(100vh - var(--header-height) - var(--footer-height));
        z-index: 1045;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    /* Show sidebar when menu is active */
    .sidebar.show {
        left: 0;
    }
    
    /* Overlay to close sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 1044;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Main content takes full width on mobile */
    .main-content {
        margin-left: 0;
        margin-top: var(--header-height);
        margin-bottom: var(--footer-height);
        width: 100%;
    }
    
    /* Header adjustments for mobile */
    .app-header {
        height: var(--header-height);
    }
    
    .app-header .header-content {
        padding: 0 1rem;
    }
    
    .app-header .header-title {
        font-size: 1.1rem;
    }
    
    /* Add mobile menu button */
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        padding: 0.5rem;
        margin-right: 0.5rem;
    }
    
    /* Footer adjustments */
    .app-footer {
        height: var(--footer-height);
        padding: 0.5rem 0;
    }
    
    .app-footer .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0 1rem;
        text-align: center;
    }
    
    .app-footer .footer-left {
        gap: 0.5rem;
    }
    
    .app-footer .footer-brand {
        font-size: 0.8rem;
    }
    
    .app-footer .footer-copyright {
        font-size: 0.65rem;
    }
    
    /* VPC items spacing for mobile */
    .vpc-item {
        padding: 0.5rem;
        margin-bottom: 0.25rem;
    }
    
    .vpc-name {
        font-size: 0.9rem;
    }
    
    .vpc-id, .vpc-cidr {
        font-size: 0.75rem;
    }
    
    /* Diagram container adjustments */
    .full-diagram-container {
        height: calc(100vh - var(--header-height) - var(--footer-height));
    }
    
    .empty-state {
        padding: 1rem;
    }
    
    .empty-state i {
        font-size: 2rem;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .app-header .header-title {
        display: none;
    }
    
    .app-header .header-content {
        padding: 0 0.5rem;
    }
    
    .sidebar {
        width: 90vw;
        max-width: none;
    }
    
    .vpc-item {
        padding: 0.4rem;
    }
    
    .vpc-controls .btn {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}

/* Desktop: Hide mobile-specific elements */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}