/* Custom font faces */
@font-face {
    font-family: 'NeutralFace';
    src: url('../fonts/heading-NeutralFace.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'FontAll';
    src: url('../fonts/font-all.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Global drag prevention */
* {
    -webkit-user-drag: none;
    -moz-user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* Allow text selection for input elements and text areas */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}

/* Global font rules */
h1, h2, h3, h4, h5, h6 {
    font-family: 'NeutralFace', 'FontAll', Arial, Helvetica, sans-serif;
}

input, select, textarea, button {
    font-family: 'FontAll', Arial, Helvetica, sans-serif;
}

/* Base styles */
body {
    font-family: 'FontAll', Arial, Helvetica, sans-serif;
    font-weight: 500;
    margin: 0;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f4f3 0%, #ebe9e7 100%);
    color: #1a1a1a;
    display: flex;
    flex-direction: column;
}

/* Override base body styles for choose-device page */
.choose-device-page body {
    height: 100vh;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f4f3 0%, #ebe9e7 100%);
}

/* Override base body styles for choose-device page */
.choose-device-page body {
    height: 100vh;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f4f3 0%, #ebe9e7 100%);
}

/* Buttons */
button, select {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    background: #ccc6c1;
    color: #222;
    cursor: pointer;
    transition: background 0.2s;
}
button:hover,
.index-page button:hover {
    background: #ab9f95;
}
button:disabled {
    background: #e5e1dd;
    cursor: not-allowed;
    color: #999;
}
.index-page button {
    padding: 15px 25px;
    font-size: 18px;
}

/* Main container */
#main-container {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f2f1f0;
    overflow: hidden;
}

/* Status */
#status {
    color: #1a1a1a;
    font-weight: 600;
    font-size: 18px;
    text-align: center;
    max-width: 80%;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 16px;
}
.error {
    color: red;
}

/* Choose Device Page - Full Screen */
.choose-device-page {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: auto;
}

.choose-device-content {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    text-align: center;
    box-sizing: border-box;
    margin: 0 auto;
}

.choose-device-content h1 {
    font-size: 2.5rem;
    color: #1a1a1a;
    margin-bottom: 2rem;
    font-weight: 600;
}

#devices-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.device-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    min-width: 250px;
    min-height: 200px;
    width: 250px;
    height: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 198, 193, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
}

.device-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.1);
}

.device-card h3 {
    font-family: 'FontAll', Arial, Helvetica, sans-serif;
    font-size: 1.5rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.device-card .device-id {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 1rem;
    font-weight: 400;
}

.connect-button {
    background: #ccc6c1;
    color: #222;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.connect-button:hover {
    background: #ab9f95;
    text-decoration: none;
}

.device-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.delete-button,
.settings-button {
    background: transparent;
    color: #6c757d;
    border: 1px solid #dee2e6;
    padding: 6px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.delete-button:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border-color: #dc3545;
    opacity: 1;
    transform: scale(1.05);
}

.settings-button:hover {
    background: rgba(108, 117, 125, 0.1);
    color: #495057;
    border-color: #6c757d;
    opacity: 1;
    transform: scale(1.05);
}

.delete-button:disabled,
.settings-button:disabled {
    background: transparent;
    color: #6c757d;
    border-color: #dee2e6;
    cursor: not-allowed;
    opacity: 0.3;
}

.device-card:hover .delete-button,
.device-card:hover .settings-button {
    opacity: 1;
}

.delete-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #dee2e6;
    border-top: 2px solid #6c757d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Add Device Card */
.add-device-card {
    background: rgba(255, 255, 255, 0.7);
    border: 2px dashed rgba(26, 26, 26, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
}

.add-device-card:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(26, 26, 26, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.1);
}

.add-device-icon {
    font-size: 4rem;
    color: rgba(26, 26, 26, 0.4);
    margin-bottom: 1rem;
    font-weight: 300;
    transition: color 0.3s ease;
    line-height: 1;
}

.add-device-card:hover .add-device-icon {
    color: rgba(26, 26, 26, 0.7);
}

.add-device-card h3 {
    font-size: 1.5rem;
    color: #1a1a1a;
    margin: 0;
    font-weight: 600;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    min-height: 200px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(26, 26, 26, 0.1);
    border-top: 4px solid #1a1a1a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-screen h3 {
    font-size: 1.5rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.loading-screen p {
    color: #666;
    font-size: 1rem;
    margin: 0;
}

/* No Devices Message */
.no-devices-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 198, 193, 0.3);
    max-width: 400px;
    margin: 0 auto;
}

.no-devices-message h3 {
    font-size: 1.5rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.no-devices-message p {
    color: #666;
    font-size: 1rem;
    margin: 0;
}

/* Error Message */
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(220, 38, 38, 0.3);
    max-width: 400px;
    margin: 0 auto;
}

.error-message h3 {
    font-size: 1.5rem;
    color: #dc2626;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.error-message p {
    color: #666;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.retry-button {
    background: #dc2626;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.retry-button:hover {
    background: #b91c1c;
}

/* Generic result card (neutral, matches failure card layout) */
.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 198, 193, 0.3);
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.result-card h3 {
    font-size: 1.5rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.result-card p {
    color: #666;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.result-card .connect-button {
    margin-top: 12px;
}

/* Add Device Page Styles */
.add-device-page {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: auto;
}

.add-device-content {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    text-align: center;
    box-sizing: border-box;
    margin: 0 auto;
}

.add-device-content h1 {
    font-size: 2.5rem;
    color: #1a1a1a;
    margin-bottom: 2rem;
    font-weight: 600;
}

.add-device-form-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 198, 193, 0.3);
}

.add-device-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.add-device-form .form-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-bottom: 1rem;
}

.add-device-form .form-group:last-child {
    margin-bottom: 0;
}

.add-device-form .form-group label {
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.add-device-form .form-group input,
.add-device-form .form-group select {
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.add-device-form .form-group input:focus,
.add-device-form .form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.add-device-form .form-help {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.cancel-button {
    background: #ccc6c1;
    color: #222;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cancel-button:hover {
    background: #ab9f95;
}

.submit-button {
    background: #ccc6c1;
    color: #222;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.submit-button:hover:not(:disabled) {
    background: #ab9f95;
}

.submit-button:disabled {
    background: #e5e1dd;
    cursor: not-allowed;
    color: #999;
}

.form-status {
    margin-top: 1rem;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
}

.form-status.success {
    background: rgba(74, 222, 128, 0.1);
    color: #16a34a;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.form-status.error {
    background: rgba(248, 113, 113, 0.1);
    color: #dc2626;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.form-status.info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Device page overrides */
.device-page #status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 16px;
    z-index: 20;
    border: 1px solid rgba(204, 198, 193, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    font-family: 'FontAll', sans-serif;
}

.device-page #main-container,
.device-page #video-container,
.device-page #video {
    min-height: 0 !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.device-page #video {
    object-fit: contain;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    background: linear-gradient(135deg, #f5f4f3 0%, #ebe9e7 100%);
    object-fit: cover;
    box-shadow: none;
}
.device-page #video-container {
    height: 100vh !important;
    aspect-ratio: 9 / 19.5;
    width: auto !important;
    max-width: 100vw !important;
    border: none !important;
    border-radius: 0;
    background: linear-gradient(135deg, #f5f4f3 0%, #ebe9e7 100%);
    box-shadow: 0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* Video container and video */
#video-container {
    position: relative;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    z-index: 5;
}
#video-container video,
video {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    background-color: #f2f1f0;
}

/* Mousepad overlay */
/* Mousepad overlay */
#mousepad-overlay {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(26,26,26,.15);
    border-radius: 0;
    pointer-events: auto;
    z-index: 10;
}


#mousepad-status {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #1a1a1a;
    font-family: 'NeutralFace', 'FontAll', sans-serif;
    font-weight: 600;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 16px;
    z-index: 15;
    border: 1px solid rgba(204, 198, 193, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
}

/* Latency display */
#latency-display {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #1a1a1a;
    font-family: 'NeutralFace', 'FontAll', sans-serif;
    font-weight: 500;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: 0;
    z-index: 15;
    border: 1px solid rgba(204, 198, 193, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
    min-width: 160px;
    line-height: 1.4;
}

/* Stats */
.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}
.stats-row:last-child {
    margin-bottom: 0;
}
.stats-label {
    color: #666;
    margin-right: 8px;
    font-weight: 500;
}
.stats-value {
    color: #1a1a1a;
    font-weight: 700;
}
.low-latency {
    color: #4ade80 !important;
}
.medium-latency {
    color: #fbbf24 !important;
}
.high-latency {
    color: #f87171 !important;
}
.stats-disconnected {
    color: #666;
    text-align: center;
    font-style: italic;
    font-weight: 500;
}

/* Index page overrides */
.index-page #main-container {
    flex-direction: column;
}
.index-page #status {
    margin-bottom: 20px;
}
.index-page #generate-button {
    border-radius: 12px;
}

/* Login page styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #f5f4f3 0%, #ebe9e7 100%);
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 198, 193, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    margin: 0 0 30px 0;
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 14px;
}

.form-group input {
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #ab9f95;
    box-shadow: 0 0 0 3px rgba(171, 159, 149, 0.1);
}

.login-button {
    padding: 14px 24px;
    background: #ccc6c1;
    color: #222;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.login-button:hover {
    background: #ab9f95;
}

.login-status {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    display: none;
}

.login-status.success {
    display: block;
    background: rgba(74, 222, 128, 0.1);
    color: #16a34a;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.login-status.error {
    display: block;
    background-color: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Old choose-device styles removed - using new full-screen layout */

.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: #ab9f95;
    box-shadow: 0 0 0 3px rgba(171, 159, 149, 0.1);
}

.input-group button {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    white-space: nowrap;
}

#generate-new-button {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
}

#generated-id-display {
    margin-top: 15px;
    padding: 15px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 8px;
}

#generated-id-display.hidden {
    display: none;
}

#generated-id-display p {
    margin: 0 0 10px 0;
    color: #16a34a;
    font-weight: 600;
}

#generated-id {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
}

#copy-id-button {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    background: #16a34a;
    color: white;
}

#copy-id-button:hover {
    background: #218838;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 198, 193, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    margin: 60px auto 60px auto;
}

/* Payment modal: show standard page background in free space (no dim overlay) */
#payment-modal {
    background: transparent;
    backdrop-filter: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(204, 198, 193, 0.2);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #1a1a1a;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
    background: rgba(204, 198, 193, 0.2);
    color: #1a1a1a;
}

.modal-body {
    padding: 2rem;
}

.modal-body .add-device-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body .edit-device-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body .form-group {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.modal-body .form-group label {
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.modal-body .form-group input {
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body .form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Registration date display styling */
.device-registered-display {
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    color: #1a1a1a;
    min-height: 20px;
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    border-color: #e9ecef;
    color: #6c757d;
}

/* Edit device form styling - ensure consistency with add device form */
.edit-device-form .form-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-bottom: 1rem;
}

.edit-device-form .form-group:last-child {
    margin-bottom: 0;
}

.edit-device-form .form-group label {
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.edit-device-form .form-group input {
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.edit-device-form .form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.edit-device-form .form-help {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

.modal-body .form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.modal-body .form-status {
    margin-top: 1rem;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
}

.modal-body .form-status.success {
    background: rgba(74, 222, 128, 0.1);
    color: #16a34a;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.modal-body .form-status.error {
    background: rgba(248, 113, 113, 0.1);
    color: #dc2626;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.modal-body .form-status.info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Animation for modal */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Restart button styles */
.restart-button {
    position: absolute;
    top: 15px;
    right: 240px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(204, 198, 193, 0.2);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    z-index: 15;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
    color: #1a1a1a;
}

.restart-button:hover {
    background: rgba(255, 255, 255, 0.95);
}

.restart-button svg {
    width: 16px;
    height: 16px;
    display: block;
}

.restart-button::before {
    content: "⚠️ Reconnect button";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    border: 1px solid rgba(204, 198, 193, 0.2);
    padding: 8px 12px;
    border-radius: 12px;
    font-family: 'FontAll', Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 30;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
}

.restart-button:hover::before {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    animation: modalFadeIn 0.2s ease-out;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-body .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Setup Mode Icon */
.setup-mode-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #ccc6c1;
    color: #222;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 100;
    border: none;
}

.setup-mode-icon:hover {
    background: #ab9f95;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 3px 10px rgba(0, 0, 0, 0.15);
}

.setup-mode-icon img {
    width: 24px;
    height: 24px;
    filter: brightness(0) saturate(100%);
}

/* Setup Mode Modal */
.setup-mode-modal .modal-content {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.setup-mode-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    border: 1px solid rgba(204, 198, 193, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.setup-requirements h3,
.setup-instructions h3 {
    margin: 0 0 15px 0;
    color: #1a1a1a;
    font-size: 16px;
}

.setup-requirements ul,
.setup-instructions ol {
    margin: 0;
    padding-left: 20px;
    color: #555;
    line-height: 1.6;
}

.setup-requirements li,
.setup-instructions li {
    margin-bottom: 8px;
}

.serial-connection-section {
    margin-bottom: 20px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    border: 1px solid rgba(204, 198, 193, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.status-indicator {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-indicator.connected {
    background: #ccc6c1;
    color: #1a1a1a;
}

.status-indicator.connecting {
    background: #f59e0b;
    color: white;
}

.status-indicator.disconnected {
    background: #ccc6c1;
    color: #1a1a1a;
}

.connect-serial-button,
.disconnect-serial-button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.connect-serial-button {
    background: #ccc6c1;
    color: #1a1a1a;
}

.connect-serial-button:hover {
    background: #ab9f95;
}

.disconnect-serial-button {
    background: #ccc6c1;
    color: #1a1a1a;
}

.disconnect-serial-button:hover {
    background: #ab9f95;
}

.simple-controls {
    margin-bottom: 20px;
}

.control-group {
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    border: 1px solid rgba(204, 198, 193, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.control-group h4 {
    margin: 0 0 15px 0;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 600;
}

.wifi-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.wifi-input {
    padding: 12px 15px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: rgba(255, 255, 255, 0.8);
}

.wifi-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.password-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-container .wifi-input {
    flex: 1;
    padding-right: 45px; /* Make room for the toggle button */
}

.toggle-password-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.toggle-password-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

.toggle-password-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.wifi-buttons {
    display: flex;
    gap: 10px;
}

.control-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.control-btn {
    padding: 12px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 6px;
    background: #ccc6c1;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover:not(:disabled) {
    background: #ab9f95;
    border-color: rgba(204, 198, 193, 0.7);
    transform: translateY(-1px);
}

.control-btn:disabled {
    background: #e5e1dd;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.status-display {
    margin-bottom: 20px;
}

.status-display h4 {
    margin: 0 0 15px 0;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 600;
}

.status-output {
    height: 300px;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    padding: 15px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(204, 198, 193, 0.3);
    display: none; /* Hidden by default */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.status-line {
    margin-bottom: 2px;
    word-wrap: break-word;
}

.status-line.sent {
    color: #007bff;
}

.status-line.received {
    color: #1a1a1a;
}

.status-line.info {
    color: #007bff;
}

.status-line.cli-prompt {
    color: #4CAF50;
    font-weight: bold;
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

.status-line.error {
    color: #f44336;
    font-weight: bold;
    background: rgba(244, 67, 54, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

.status-line.success {
    color: #4CAF50;
    font-weight: bold;
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Responsive setup mode */
@media (max-width: 768px) {
    .setup-mode-info {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .setup-mode-modal .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .status-output {
        height: 250px;
    }
    
    .control-buttons {
        grid-template-columns: 1fr;
    }
    
    .wifi-buttons {
        flex-direction: column;
    }
}

/* Wide modal for setup mode */
.wide-modal {
    max-width: 1200px !important;
    width: 90vw !important;
}

.wide-modal .modal-body {
    padding: 30px;
}

.wide-modal .serial-connection-section {
    margin-bottom: 30px;
}

/* Status section with toggle */
.status-section {
    margin-bottom: 20px;
}

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

.status-header h4 {
    margin: 0;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 600;
}

.toggle-status-button {
    padding: 8px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 6px;
    background: #ccc6c1;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-status-button:hover {
    background: #ab9f95;
    border-color: rgba(204, 198, 193, 0.7);
}

.toggle-status-button.showing {
    background: #ab9f95;
    color: #1a1a1a;
    border-color: #ab9f95;
}

.toggle-status-button.showing:hover {
    background: #9a8f85;
}

/* Console section */
.console-section {
    margin-bottom: 20px;
}

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

.console-header h4 {
    margin: 0;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 600;
}

.toggle-console-button {
    padding: 8px 16px;
    border: 1px solid rgba(204, 198, 193, 0.5);
    border-radius: 6px;
    background: #ccc6c1;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-console-button:hover {
    background: #ab9f95;
    border-color: rgba(204, 198, 193, 0.7);
}

.toggle-console-button.showing {
    background: #ab9f95;
    color: #1a1a1a;
    border-color: #ab9f95;
}

.toggle-console-button.showing:hover {
    background: #9a8f85;
}

/* Status logs styling */
.status-logs {
    min-height: 100px;
    max-height: 200px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(204, 198, 193, 0.3);
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    display: block; /* Visible by default */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.status-logs .log-entry {
    margin-bottom: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    border-left: 3px solid transparent;
}

.status-logs .log-entry.info {
    background: rgba(0, 123, 255, 0.1);
    border-left-color: #007bff;
    color: #0056b3;
}

.status-logs .log-entry.success {
    background: rgba(76, 175, 80, 0.1);
    border-left-color: #4CAF50;
    color: #388E3C;
}

.status-logs .log-entry.error {
    background: rgba(244, 67, 54, 0.1);
    border-left-color: #f44336;
    color: #d32f2f;
}

.status-logs .log-entry.warning {
    background: rgba(255, 152, 0, 0.1);
    border-left-color: #FF9800;
    color: #f57c00;
}

/* Last console line display when logs are hidden */
.last-console-line {
    min-height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(204, 198, 193, 0.3);
    border-radius: 8px;
    padding: 12px 15px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: none;
}

.last-console-line .last-line-display {
    color: #1a1a1a;
    word-wrap: break-word;
}

.last-console-line:empty {
    display: none;
}

/* Move setup info to bottom */
.setup-mode-info {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Floating Setup Mode Icon */
.setup-mode-float-icon {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: #ccc6c1;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 9999;
    color: #1a1a1a;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.setup-mode-float-icon:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    background: #ab9f95;
}

.setup-mode-float-icon svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

.setup-icon-text {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* Responsive floating icon */
@media (max-width: 768px) {
    .setup-mode-float-icon {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
    
    .setup-mode-float-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .setup-icon-text {
        font-size: 8px;
    }
}