/* General styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f7f9;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 800px;
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 20px;
}

header h1 {
    font-size: 2.5em;
    color: #007bff;
    margin: 0;
}

header p {
    font-size: 1.1em;
    color: #666;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.card {
    background-color: #fff;
    padding: 1.5rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.error-card {
    text-align: center;
    background-color: #ffebee; /* 淡红色背景 */
    color: #c62828; /* 深红色文字 */
    border: 1px solid #ef9a9a;
}

.error-card h2 {
    margin-top: 0;
    color: #b71c1c;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

/* Sender and Receiver areas */
.sender-area, .receiver-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

button {
    padding: 12px 20px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    transition: background-color 0.3s ease;
}

.share-link-container {
    display: flex;
    margin: 0.5rem 0;
}

.share-link-container input {
    flex-grow: 1;
    border: 1px solid #ddd;
    padding: 0.6rem 0.8rem;
    border-radius: 5px 0 0 5px;
    background-color: #f9f9f9;
    color: #333;
    font-size: 0.9rem;
    border-right: none;
}

.share-link-container button {
    border-radius: 0 5px 5px 0;
    white-space: nowrap; /* 防止按钮文字换行 */
}

.room-code-divider {
    text-align: center;
    margin: 1rem 0 0.5rem;
    position: relative;
    color: #999;
}

.room-code-divider::before,
.room-code-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background-color: #eee;
}

.room-code-divider::before {
    left: 0;
}

.room-code-divider::after {
    right: 0;
}

.room-code-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f9f9f9;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    border: 1px solid #eee;
}

.room-code-container p {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

.room-code-container span {
    font-weight: bold;
    color: #4CAF50;
    margin-left: 0.5rem;
}

#join-room-btn {
    background-color: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

#join-room-btn:hover {
    background-color: #45a049;
    border-color: #45a049;
}

/* --- Speed Stats Styles --- */
#speed-stats {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.8rem;
    text-align: center;
}

.speed-divider {
    margin: 0 0.5rem;
    color: #ccc;
}

/* --- Peer List Styles --- */
#peer-list-section {
    padding: 1rem 1.5rem;
}
#peer-list-section h4 {
    margin-top: 0;
    margin-bottom: 0.8rem;
    color: #333;
}
#peer-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #555;
    max-height: 100px;
    overflow-y: auto;
}
#peer-list .my-peer-id {
    font-weight: bold;
    color: #4CAF50;
}

/* --- Keep Awake Section Styles --- */
#keep-awake-section {
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.keep-awake-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 500;
}

.auto-disable-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

/* --- Toggle Switch CSS --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:focus + .slider {
    box-shadow: 0 0 1px #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}


button:hover {
    background-color: #357ABD;
}

input[type="text"], input[type="file"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box; /* Ensure padding doesn't add to width */
    width: 100%; /* Make inputs take full width of container */
}

#room-info {
    margin-top: 15px;
}

#copy-code-btn {
    margin-left: 0; /* Remove margin, use gap instead */
    flex-shrink: 0; /* Prevent the copy button from shrinking */
    background-color: #28a745;
    padding: 5px 10px;
}

#copy-code-btn:hover {
    background-color: #218838;
}

.share-tip {
    font-size: 0.9em;
    color: #888;
    margin-top: 10px;
}

/* Status area */
#status-area {
    margin-top: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #eee;
}

#status-area h3 {
    margin-top: 0;
}

#status-messages {
    font-family: 'Courier New', Courier, monospace;
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 5px;
    min-height: 50px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.9em;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    color: #999;
}

/* Utility classes */
.hidden {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }

    header {
        position: relative;
    }
}

/* Checkbox styles */
.checkbox-container {
    display: flex;
    align-items: center;
    margin-top: 15px;
    gap: 8px;
}

.checkbox-container label {
    cursor: pointer;
    color: #555;
}

/* Public rooms section */
#public-rooms-section {
    margin-top: 30px;
}

#public-rooms-list table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#public-rooms-list th, #public-rooms-list td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#public-rooms-list th {
    background-color: #f8f9fa;
    font-weight: 600;
}

#public-rooms-list tr:hover {
    background-color: #f1f1f1;
}

#public-rooms-list .join-btn {
    padding: 6px 12px;
    font-size: 0.9em;
    background-color: #28a745;
}
#public-rooms-list .join-btn:hover {
    background-color: #218838;
}

#public-rooms-list .no-rooms {
    text-align: center;
    color: #888;
    padding: 20px;
}

#how-to-use-btn {
    margin-top: 15px;
    background-color: #6c757d;
    padding: 8px 15px;
    font-size: 0.9em;
}
#how-to-use-btn:hover {
    background-color: #5a6268;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}
.modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0);
}


.modal-content h2 {
    margin-top: 0;
    text-align: center;
    color: #007bff;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #aaa;
    line-height: 1;
}
.close-btn:hover {
    color: #333;
}

.instructions {
    display: flex;
    gap: 25px;
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.instruction-step h3 {
    margin-top: 0;
    font-size: 1.2em;
}

.instruction-step ol {
    padding-left: 20px;
    line-height: 1.8;
}

.modal-tip {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 0.9em;
    color: #666;
    text-align: center;
}

@media (max-width: 640px) {
    .instructions {
        flex-direction: column;
    }
}

/* --- File List Styles --- */
.file-list {
    border: 1px solid #eee;
    border-radius: 5px;
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #eee;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

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

.file-item-size {
    font-size: 0.85rem;
    color: #777;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 1rem;
}

.file-item-actions button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

#add-files-btn {
    margin-top: 1rem;
    width: 100%;
}

.button-secondary {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    color: #333;
}

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

/* --- File Drop Zone --- */
.file-drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    background-color: #f9f9f9;
    color: #666;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    margin-top: 1rem;
}

.file-drop-zone:hover {
    background-color: #f0f0f0;
    border-color: #bbb;
}

.file-drop-zone.dragover {
    background-color: #e0e8f0;
    border-color: #007bff;
    color: #0056b3;
}

.button-link {
    background: none;
    border: none;
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: inherit; /* 继承父元素的字体大小 */
}

.button-link:hover {
    color: #0056b3;
    background: none;
}
