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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a4d6e 0%, #2c5f7a 50%, #1a5f5f 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: stretch;
}

.column {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, filter 0.3s ease;
    min-height: 100%;
}

.column.inactive {
    opacity: 0.6;
    filter: grayscale(0.8);
    background: #f0f0f0;
    position: relative;
}

.column.inactive::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(200, 200, 200, 0.3);
    border-radius: 16px;
    pointer-events: none;
    z-index: 1;
}

.column h2 {
    margin-bottom: 20px;
    color: #1a4d6e;
    font-size: 1.5em;
    text-align: center;
}

.setup-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.file-upload-area {
    border: 3px dashed #1a4d6e;
    border-radius: 12px;
    background: #f8f9fa;
    transition: all 0.3s ease;
    margin-bottom: 10px;
    overflow: hidden;
}

.file-upload-area.collapsed {
    padding: 12px 20px;
}

.file-upload-area:not(.collapsed) {
    padding: 20px;
}

.file-upload-area:not(.collapsed):hover {
    border-color: #2c5f7a;
    background: #e9ecef;
    transform: translateY(-2px);
}

.file-upload-area.drag-over {
    border-color: #00aa00;
    background: #e8f5e9;
}

.file-upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.file-upload-content {
    text-align: center;
    flex: 1;
}

.file-upload-body {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.file-upload-area.collapsed .file-upload-body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.file-upload-area:not(.collapsed) .file-upload-body {
    max-height: 1000px;
    opacity: 1;
    margin-top: 15px;
}

.collapse-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
    color: #1a4d6e;
    font-size: 16px;
    transition: transform 0.3s ease, color 0.2s ease;
    border-radius: 4px;
}

.collapse-btn:hover {
    background: rgba(26, 77, 110, 0.1);
    color: #2c5f7a;
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.file-upload-area.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.file-upload-text {
    font-size: 16px;
    font-weight: 600;
    color: #1a4d6e;
    margin-bottom: 8px;
}

.file-upload-hint {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.file-list {
    margin-top: 15px;
    display: none;
}

.file-list.show {
    display: block;
}

.file-item {
    background: white;
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 6px;
    border-left: 4px solid #1a4d6e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.file-item-name {
    font-weight: 600;
    color: #333;
}

.file-item-status {
    font-size: 12px;
    color: #666;
}

.file-item-status.ready {
    color: #00aa00;
    font-weight: 600;
}

.delete-item {
    background: #fff5f5 !important;
    border-left-color: #aa0000 !important;
}

.delete-item:hover {
    background: #ffe0e0 !important;
}

.delete-button {
    width: 100%;
    text-align: center;
    display: block;
}

.model-categories {
    margin-top: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #1a4d6e;
    min-height: 50px;
    display: none;
}

.model-categories.show {
    display: block;
}

.model-categories h4 {
    color: #1a4d6e;
    margin-bottom: 10px;
    font-size: 1em;
}

.category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tag {
    background: linear-gradient(135deg, #1a4d6e 0%, #2c5f7a 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.btn-primary {
    width: 100%;
    padding: 14px 20px;
    margin: 10px 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #1a4d6e 0%, #2c5f7a 100%);
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(26, 77, 110, 0.5);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 77, 110, 0.7);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    margin: 10px 0;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #1a4d6e;
    border-radius: 8px;
    background: white;
    color: #1a4d6e;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 2px 8px rgba(26, 77, 110, 0.2);
}

.btn-secondary:hover {
    background: #f0f8ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 77, 110, 0.3);
}

.btn-secondary:active {
    transform: translateY(0);
}

.label-color-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #1a4d6e;
}

.label-color-section h3 {
    margin-bottom: 15px;
    color: #1a4d6e;
    font-size: 1.1em;
}

.label-color-pickers {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.label-color-tag {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    user-select: none;
}

.label-color-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.label-color-tag:active {
    transform: translateY(0);
}

.label-color-input-hidden {
    display: none;
}

/* Label List Styles */
.label-list-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.label-list-section h3 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 1.1em;
}

.label-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.label-list-item {
    padding: 10px 15px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.label-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.label-action-info {
    font-size: 0.85em;
    opacity: 0.8;
}

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

.label-choice-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    text-align: center;
}

.label-choice-content h4 {
    margin-bottom: 20px;
    color: #495057;
}

.label-choice-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    border: none;
    border-radius: 6px;
    background: #1a4d6e;
    color: white;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.label-choice-btn:hover {
    background: #2c5f7a;
}

.label-choice-close {
    background: #6c757d;
}

.label-choice-close:hover {
    background: #5a6268;
}

/* Color Picker Modal (Right Corner) */
.color-picker-modal {
    justify-content: flex-end;
    align-items: flex-start;
    padding: 20px;
}

.color-picker-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    min-width: 280px;
    margin-right: 20px;
    margin-top: 20px;
}

.color-picker-content h4 {
    margin-bottom: 15px;
    color: #495057;
}

.color-picker-input {
    width: 100%;
    height: 60px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 15px;
}

.color-picker-actions {
    display: flex;
    gap: 10px;
}

.color-picker-actions button {
    flex: 1;
}

/* Action Selector Modal */
.action-selector-modal {
    justify-content: center;
    align-items: center;
}

.action-selector-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.1);
    min-width: 420px;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.action-selector-content h4 {
    margin-bottom: 25px;
    color: #1a4d6e;
    font-size: 1.3em;
    font-weight: 600;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.action-selector-body {
    margin-bottom: 25px;
}

.action-select-modal {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 20px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.action-select-modal:hover {
    border-color: #1a4d6e;
    box-shadow: 0 2px 8px rgba(26, 77, 110, 0.15);
}

.action-select-modal:focus {
    outline: none;
    border-color: #1a4d6e;
    box-shadow: 0 0 0 3px rgba(26, 77, 110, 0.1);
}

.action-params-modal {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e9ecef;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-left: -5px;
    margin-right: -5px;
}

.action-params-modal .action-params-roll,
.action-params-modal .action-params-angle,
.action-params-modal .action-params-matrix {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Parameter group styling - each input on its own line */
.param-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.param-group:last-child {
    margin-bottom: 0;
}

.param-label {
    font-size: 0.95em;
    color: #495057;
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
}

.param-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    color: #495057;
    transition: all 0.2s ease;
}

.param-input:hover {
    border-color: #1a4d6e;
}

.param-input:focus {
    outline: none;
    border-color: #1a4d6e;
    box-shadow: 0 0 0 3px rgba(26, 77, 110, 0.1);
}

.action-params-modal input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.action-params-modal input[type="color"]:hover {
    border-color: #1a4d6e;
}

/* Action selector close button */
#action-selector-close {
    width: 100%;
    padding: 12px 20px;
    margin-top: 20px;
    background: #1a4d6e;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(26, 77, 110, 0.2);
}

#action-selector-close:hover {
    background: #2c5f7a;
    box-shadow: 0 4px 12px rgba(26, 77, 110, 0.3);
    transform: translateY(-1px);
}

#action-selector-close:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(26, 77, 110, 0.2);
}

/* Label Action Selector Styles */
.label-action-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.label-action-section h3 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 1.1em;
}

.label-action-selectors {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.label-action-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.label-action-name {
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
}

.label-action-select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 0.9em;
    color: #495057;
    cursor: pointer;
    transition: border-color 0.2s;
}

.label-action-select:hover {
    border-color: #80bdff;
}

.label-action-select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.label-action-params {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.action-params-roll,
.action-params-angle,
.action-params-matrix {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.action-params-roll label,
.action-params-angle label,
.action-params-matrix label {
    font-size: 0.85em;
    color: #6c757d;
    font-weight: 500;
}

.action-param-speed,
.action-param-heading,
.action-param-angle {
    padding: 5px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9em;
    width: 100%;
    max-width: 200px;
}

.action-param-color {
    width: 60px;
    height: 35px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
}

.status {
    text-align: center;
    padding: 10px;
    margin: 15px 0;
    border-radius: 8px;
    background: #f0f0f0;
    font-weight: 600;
    color: #aa0000;
}

.webcam-box {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

.webcam-placeholder {
    color: #888;
    font-style: italic;
}

#webcam-container canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    background: #000;
    border-radius: 12px;
}

/* Ensure video is visible and properly sized */
#webcam-container video,
#webcam-container canvas {
    object-fit: contain;
    max-height: 400px;
}

.predictions {
    margin-bottom: 25px;
}

.prediction-item {
    padding: 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    border-left: 4px solid #1a4d6e;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prediction-label {
    display: block;
    font-weight: 600;
    color: #333;
}

.prediction-bar-container {
    width: 100%;
    height: 24px;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    position: relative;
}

.prediction-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #1a4d6e 0%, #2c5f7a 100%);
    border-radius: 4px;
    transition: width 0.3s ease-out;
    min-width: 0;
}

.gesture-display {
    background: linear-gradient(135deg, #1a4d6e 0%, #2c5f7a 100%);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 25px;
    color: white;
}

.gesture-display h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
}

.gesture-name {
    font-size: 2.5em;
    font-weight: bold;
    margin: 15px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confidence {
    font-size: 1.1em;
    opacity: 0.9;
    margin-top: 10px;
}

.debug-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #1a4d6e;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.debug-section h3 {
    margin-bottom: 15px;
    color: #1a4d6e;
    font-size: 1.2em;
}

.debug-terminal {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 15px;
    border-radius: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    line-height: 1.6;
    border: 2px solid #333;
    height: 150px;
    max-height: 150px;
}

.debug-terminal::-webkit-scrollbar {
    width: 8px;
}

.debug-terminal::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

.debug-terminal::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.debug-terminal::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.debug-log {
    margin: 2px 0;
    padding: 2px 0;
}

.debug-log-time {
    color: #858585;
    margin-right: 8px;
}

.debug-log-info {
    color: #4ec9b0;
}

.debug-log-success {
    color: #4ec9b0;
}

.debug-log-action {
    color: #569cd6;
}

.debug-log-error {
    color: #f48771;
}

.debug-log-warning {
    color: #dcdcaa;
}

.virtual-matrix {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 2px;
    width: 240px;
    height: 240px;
    background: #000;
    padding: 8px;
    border-radius: 8px;
    border: 3px solid #333;
    margin: 10px auto;
}

.matrix-pixel {
    background: #000;
    border-radius: 2px;
    transition: background-color 0.2s ease;
    aspect-ratio: 1;
}

.matrix-info {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #333;
    margin-top: 10px;
    padding: 8px;
    background: #e9ecef;
    border-radius: 4px;
}

.movement-status {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #333;
    margin-top: 10px;
    padding: 8px;
    background: #e9ecef;
    border-radius: 4px;
}

/* Responsive design for tablets/iPads */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .gesture-name {
        font-size: 2em;
    }
}

/* Responsive design for phones */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.5em;
    }
    
    .column {
        padding: 15px;
    }
    
    .gesture-name {
        font-size: 1.5em;
    }
}
