* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary: #4a6cf7;
    --secondary: #6c757d;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --light: #f8f9fa;
    --dark: #212529;
    --background: #f4f7fe;
    --card-bg: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border: #e2e8f0;
    --pi-primary: #14bca8;
    --pi-secondary: #0d8e7e;
    --trigger-color: #e83e8c;
    --app-color: #4a6cf7;
    --data-color: #20c997;
    --logic-color: #fd7e14;
    --file-color: #6f42c1;
    --utility-color: #6c757d;
}

body {
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary), #3a56d4);
    color: white;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

.logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.logo h1 {
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo span {
    font-weight: 300;
    font-size: 14px;
    opacity: 0.8;
}

.menu {
    flex: 1;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-left: 4px solid white;
}

.user-section {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: bold;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    opacity: 0.8;
}

/* Main Content Styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.header {
    background-color: var(--card-bg);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--light);
    border-radius: 20px;
    padding: 5px 15px;
    width: 300px;
}

.search-bar input {
    border: none;
    background: transparent;
    padding: 8px;
    width: 100%;
    outline: none;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background-color: #3a56d4;
}

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

.btn-pi:hover {
    background-color: var(--pi-secondary);
}

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

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

/* Dashboard Styles */
.dashboard {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

.section-title {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title h2 {
    font-size: 20px;
    font-weight: 600;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.04);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.card-title {
    font-weight: 600;
    margin-bottom: 10px;
}

.card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.card-actions {
    display: flex;
    justify-content: space-between;
}

/* Workflow Editor */
.workflow-editor {
    display: none;
    flex-direction: column;
    height: 100%;
}

.editor-header {
    padding: 15px 25px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.node-palette {
    width: 250px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
}

.node-category {
    margin-bottom: 20px;
}

.node-category-title {
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.node-category-title i {
    font-size: 14px;
}

.node-items-container {
    display: grid;
    gap: 8px;
}

.node-item {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: move;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.node-item:hover {
    background-color: var(--light);
}

.canvas-container {
    flex: 1;
    position: relative;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><rect width="20" height="20" fill="none"/><path d="M0 10L20 10M10 0L10 20" stroke="%23e2e8f0" stroke-width="0.5"/></svg>');
    overflow: auto;
}

.canvas {
    position: relative;
    width: 5000px;
    height: 5000px;
}

.node {
    position: absolute;
    width: 200px;
    background-color: var(--card-bg);
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    cursor: move;
    user-select: none;
    z-index: 10;
    transition: box-shadow 0.3s ease, opacity 0.3s ease;
}

.node-header {
    padding: 8px 12px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    cursor: grab;
    user-select: none;
}

.node-header:active {
    cursor: grabbing;
}

.node-content {
    padding: 12px;
    font-size: 13px;
}

.node-io {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.input-point, .output-point {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--secondary);
    cursor: crosshair;
    transition: transform 0.2s ease;
    position: relative;
}

.input-point:hover, .output-point:hover {
    transform: scale(1.2);
}

.output-point {
    background-color: var(--success);
}

.connection {
    position: absolute;
    background-color: var(--primary);
    transform-origin: 0 0;
    z-index: 5;
    pointer-events: none;
}

.connection-point {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--primary);
    z-index: 15;
    cursor: pointer;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
}

/* Node type colors */
.node-trigger .node-header { background-color: var(--trigger-color); }
.node-app .node-header { background-color: var(--app-color); }
.node-data .node-header { background-color: var(--data-color); }
.node-logic .node-header { background-color: var(--logic-color); }
.node-file .node-header { background-color: var(--file-color); }
.node-utility .node-header { background-color: var(--utility-color); }
.node-pi .node-header { background-color: var(--pi-primary); }

/* Pi Connect Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.pi-connect-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pi-option {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pi-option:hover {
    border-color: var(--pi-primary);
    background-color: rgba(20, 188, 168, 0.05);
}

.pi-option-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: 100vh;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 10px;
        order: 2;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 100;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.mobile-open {
        transform: translateY(0);
    }
    
    .main-content {
        width: 100%;
        order: 1;
        padding-bottom: 70px;
    }
    
    .sidebar .menu {
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .sidebar .menu-item {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 10px 15px;
    }
    
    .user-section {
        display: none;
    }
    
    .header {
        padding: 10px 15px;
        flex-wrap: wrap;
    }
    
    .search-bar {
        width: 100%;
        order: 2;
        margin-top: 10px;
    }
    
    .header-actions {
        order: 1;
        width: 100%;
        justify-content: space-between;
    }
    
    .header-actions .btn {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .dashboard {
        padding: 15px;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .editor-content {
        flex-direction: column;
    }
    
    .node-palette {
        width: 100%;
        height: 200px;
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        flex-direction: column;
    }
    
    .node-category {
        flex: 0 0 auto;
        margin-bottom: 15px;
        margin-right: 15px;
        width: 200px;
    }
    
    .node-category-title {
        white-space: nowrap;
    }
    
    .node-items-container {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 5px;
    }
    
    .node-item {
        flex: 0 0 auto;
        width: 120px;
        margin-bottom: 0;
    }
    
    .canvas-container {
        height: 400px;
    }
    
    .node {
        width: 180px;
        font-size: 12px;
    }
    
    .node-header {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .node-content {
        padding: 8px;
    }
    
    .form-group {
        margin-bottom: 8px;
    }
    
    .form-group input, 
    .form-group select, 
    .form-group textarea {
        padding: 5px;
        font-size: 11px;
    }
    
    /* Mobile menu toggle */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        background-color: var(--primary);
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        border: none;
    }
    
    /* Touch-friendly button sizes */
    .btn {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .node-item {
        min-height: 44px;
    }
    
    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Very small devices */
@media (max-width: 360px) {
    .header-actions .btn {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .btn span {
        display: none;
    }
    
    .btn i {
        margin-right: 0;
    }
    
    .node {
        width: 160px;
    }
}

/* Mobile landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100%;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .node-header {
        cursor: default;
    }
    
    .node-header:active {
        cursor: default;
    }
    
    .input-point, .output-point {
        width: 16px;
        height: 16px;
    }
    
    /* Increase touch targets */
    .menu-item {
        min-height: 44px;
    }
    
    .card {
        min-height: 120px;
    }
}

/* Utility Classes */
.text-sm {
    font-size: 14px;
}

.text-xs {
    font-size: 12px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

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

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

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

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

/* Login Form */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary), #3a56d4);
    padding: 20px;
}

.login-form {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.login-form h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.login-btn:hover {
    background-color: #3a56d4;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}

.pi-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background-color: var(--pi-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 15px;
}

.pi-login-btn:hover {
    background-color: var(--pi-secondary);
}

/* Visual feedback for dragging */
.node-moving {
    opacity: 0.8;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2) !important;
    z-index: 1000 !important;
}

.connection-line {
    stroke: var(--primary);
    stroke-width: 2;
    fill: none;
}

.connection-handle {
    fill: var(--primary);
    cursor: pointer;
}

.connection-handle:hover {
    fill: var(--secondary);
}
