/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.5rem;
}

/* Separator */
.separator {
    border: none;
    height: 2px;
    background-color: #e0e0e0;
    margin: 30px 0;
}

/* Editor header styling */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.editor-header h2 {
    margin-bottom: 0; /* Remove the bottom margin from the h2 */
}

.editor-controls {
    display: flex;
    gap: 10px;
}

.editor-button {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.editor-button:hover  {
    background-color: #0069d9;
}

#reset-defaults {
    background-color: #6c757d;
}

#reset-defaults:hover {
    background-color: #5a6268;
}

/* Connection screen styles */
#connection-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
}

#connection-screen h2 {
    margin-bottom: 20px;
    font-size: 1.8rem;
}

#connection-screen p {
    margin-bottom: 30px;
    color: #666;
    font-size: 1.1rem;
}

#authorize-device, #try-again {
    padding: 12px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#authorize-device:hover, #try-again {
    background-color: #0069d9;
}

#authorize-device:active {
    transform: scale(0.98);
}


/* Key squares styling */
.key-square {
    width: 80px;
    height: 80px;
    border: 2px solid #333;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3px;
    position: relative;
    background-color: #fff;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    font-size: 0.9rem;
}

/* Programmable keys section */
.editor-section {
    margin-bottom: 20px;
}

/* Programmable keys grid styling */
.programmable-keys-grid {
    display: grid;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    justify-items: center;
}

/* Update the programmable keys container */
.programmable-keys {
    margin-bottom: 20px;
    width: 100%;
}

.assigned-keycode {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    text-align: center;
    word-break: break-word;
    padding: 4px;
}

.drop-zone {
    background-color: #f9f9f9;
    border: 2px dashed #999;
}

.drop-zone.highlight {
    background-color: #e6f7ff;
    border: 2px dashed #1890ff;
}

.drop-zone.has-keycode {
    border: 2px solid #333;
    background-color: #fff;
}

/* Available keycodes grid */
.keycode-section {
    margin-top: 20px;
}

.keycode-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(5, 1fr); /* Limit to 5 rows */
    gap: 8px;  /* Reduced from 10px */
    margin-bottom: 10px;
    min-height: 360px; /* Ensures consistent height across pages */
}

/* Draggable keycode styling */
.draggable {
    cursor: grab;
    transition: transform 0.1s, box-shadow 0.1s;
}

.draggable:active {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Short description text */
.short-description {
    font-size: 0.65rem;
    text-align: center;
    word-break: break-word;
    padding: 2px;
}

/* Tooltip styling */
.tooltip {
    position: fixed; /* Changed from absolute to fixed */
    display: none;
    background-color: #333;
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    max-width: 300px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: none; /* Prevents the tooltip from interfering with mouse events */
}

/* OS support indicators */
.os-support {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.os-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
}

.supported {
    color: green;
}

.not-supported {
    color: red;
    opacity: 0.5;
}

/* Clone styling for drag operation */
.dragging-clone {
    position: fixed; 
    pointer-events: none;
    opacity: 0.8;
    z-index: 1000;
}


/* Filter buttons styling */
.filter-buttons {
    display: flex;
    justify-content: center;
    margin: 0 0 15px 0;
    gap: 10px;
}

.filter-button {
    padding: 8px 20px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.filter-button:hover {
    background-color: #e0e0e0;
}

.filter-button.active {
    background-color: #007bff;
    color: white;
    border-color: #0069d9;
}

/* Add this to your CSS */
.status-messages {
    margin: 10px 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
}

.status-message {
    padding: 8px;
    margin: 5px 0;
    border-radius: 4px;
    position: relative;
}

.status-message::before {
    content: attr(data-timestamp);
    font-size: 0.8em;
    opacity: 0.7;
    margin-right: 8px;
}

.status-message.info {
    background-color: #e3f2fd;
    color: #1565c0;
}

.status-message.success {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.status-message.error {
    background-color: #ffebee;
    color: #c62828;
}

.status-message.warning {
    background-color: #fff3e0;
    color: #e65100;
}

/* Add pagination controls styling */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
    gap: 10px;
}

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

.modal-content {
    background-color: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

.modal-title {
    font-size: 1.4rem;
    margin-bottom: 16px;
    color: #333;
}

.modal-message {
    margin-bottom: 24px;
    color: #666;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.modal-button.cancel {
    background-color: #f0f0f0;
    color: #333;
}

.modal-button.cancel:hover {
    background-color: #e0e0e0;
}

.modal-button.confirm {
    background-color: #007bff;
    color: white;
}

.modal-button.confirm:hover {
    background-color: #0069d9;
}

.pagination-controls button {
    padding: 5px 12px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.pagination-controls button:hover {
    background-color: #e0e0e0;
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    margin: 0 10px;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .keycode-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .key-square {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .keycode-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}