/* Main CSS Styles for Python GUI Designer */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: white;
    font-size: 18px;
}

.loading i {
    font-size: 48px;
    margin-bottom: 20px;
}

/* Main Application Layout */
.app-container {
    display: flex;
    height: 100vh;
    background: #f5f5f5;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 60px;
}

.app-title {
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.app-title i {
    margin-right: 10px;
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    margin-top: 60px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-section {
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-header {
    padding: 15px 20px;
    background: #f8f9fa;
    font-weight: bold;
    color: #495057;
    border-bottom: 1px solid #e0e0e0;
}

/* Widget Palette */
.widget-palette {
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.widget-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.widget-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    background: white;
    text-align: center;
}

.widget-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

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

.widget-item i {
    font-size: 24px;
    color: #667eea;
    margin-bottom: 8px;
}

.widget-item span {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

/* Library Selector */
.library-selector {
    padding: 15px 20px;
}

.library-selector select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

/* Layout Controls */
.layout-controls {
    padding: 15px 20px;
}

.layout-buttons {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.layout-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.layout-btn:hover {
    background: #f0f0f0;
}

.layout-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 60px;
}

.content-header {
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.window-properties {
    display: flex;
    gap: 15px;
    align-items: center;
}

.window-properties input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    display: flex;
    position: relative;
    background: #f8f9fa;
}

.design-canvas {
    flex: 1;
    background: white;
    margin: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow: auto;
    min-height: 500px;
}

.canvas-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 20px;
}

/* Dropped Widgets */
.dropped-widget {
    position: absolute;
    border: 2px dashed transparent;
    border-radius: 4px;
    cursor: move;
    transition: all 0.2s;
    min-width: 80px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.1);
}

.dropped-widget:hover {
    border-color: #667eea;
}

.dropped-widget.selected {
    border-color: #667eea;
    border-style: solid;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.dropped-widget .widget-content {
    pointer-events: none;
    font-size: 14px;
    color: #333;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    background: #667eea;
    border: 1px solid #fff;
    border-radius: 2px;
    z-index: 10;
}

.resize-handle-right {
    top: 50%;
    right: -4px;
    width: 8px;
    height: 20px;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.resize-handle-bottom {
    bottom: -4px;
    left: 50%;
    width: 20px;
    height: 8px;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.resize-handle-corner {
    bottom: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    cursor: nw-resize;
}

/* Property Panel */
.property-panel {
    width: 300px;
    background: white;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

.property-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    font-weight: bold;
    color: #495057;
}

.property-content {
    padding: 20px;
    overflow-y: auto;
}

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

.property-group h4 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
}

.property-field {
    margin-bottom: 15px;
}

.property-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.property-field input,
.property-field select,
.property-field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.property-field input:focus,
.property-field select:focus,
.property-field textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.code-container {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Drag and Drop States */
.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed #667eea;
}

.dragging {
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .sidebar {
        width: 250px;
    }
    
    .property-panel {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
        order: 2;
    }
    
    .main-content {
        order: 1;
    }
    
    .property-panel {
        width: 100%;
        height: auto;
        max-height: 300px;
        order: 3;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}