/* General Body & Typography */
body {
    font-family: sans-serif;
    line-height: 1.6;
    margin: 20px; /* Base margin */
    padding-top: 60px; /* Consistent top padding for header */
    background-color: #f4f4f4;
    color: #333;
}

h1, h2 {
    color: #555;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
}
h1 {
    text-align: center; /* Center main H1 */
    margin-top: 0; /* Remove default top margin */
}

/* Apply border-box sizing globally */
*, *:before, *:after {
    box-sizing: border-box;
}

/* --- Header Elements (Auth Status & Theme Toggle) --- */
.auth-status {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 0.9em;
    color: #555;
    z-index: 1000;
}
.auth-status a {
    color: #007bff;
    text-decoration: none;
}
.auth-status a:hover {
    text-decoration: underline;
}

.theme-toggle {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    align-items: center;
    z-index: 1000;
}
.theme-toggle-label {
    margin-left: 8px;
    font-size: 0.9em;
    color: #555;
    cursor: pointer;
}

/* Basic Checkbox Toggle Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 40px; /* Width of the toggle */
    height: 20px; /* Height of the toggle */
}
.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: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: #007bff; }
input:focus + .slider { box-shadow: 0 0 1px #007bff; }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 20px; }
.slider.round:before { border-radius: 50%; }

/* --- Toast Notifications --- */
#toast-container {
position: fixed; top: 70px; /* Adjusted top slightly for body padding */ right: 20px; z-index: 1050; width: 300px; display: flex; flex-direction: column; gap: 10px;
}
.toast { background-color: #333; color: #fff; padding: 15px 20px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); opacity: 0; transition: opacity 0.5s ease-out, transform 0.5s ease-out; position: relative; transform: translateX(100%); }
.toast.show { opacity: 0.95; transform: translateX(0); }
.toast.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.toast.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.toast.warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.toast.info { background-color: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.toast .close-button { position: absolute; top: 5px; right: 10px; background: none; border: none; color: inherit; font-size: 1.2em; cursor: pointer; opacity: 0.7; }
.toast .close-button:hover { opacity: 1; }

/* --- Page Specific Containers & Elements --- */

/* Main Index Page (index.html) */
.status-section, .logs-section {
    background-color: #fff;
    padding: 15px 20px;
    margin: 20px auto; /* Center main sections */
    max-width: 900px; /* Limit width */
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center
}
#server-status {
font-weight: bold;
padding: 2px 8px;
border-radius: 4px;
color: white;
max-width: 125px;
min-width: 125px;

/* Add these lines for horizontal centering */
display: block; /* Ensure it's treated as a block */
margin-left: auto;
margin-right: auto;
margin-top: 24px;
text-align: center;
}

.status-running { background-color: #28a745; }
.status-stopped { background-color: #dc3545; }
.logs-section h2 { margin-top: 0;} /* Adjust spacing */
.logs-section .nav-links { margin-bottom: 15px; } /* Style nav links here too */

/* Command Input Area (index.html) */
.logs-section > form { /* Targets the direct form child of .logs-section */
    display: flex;      /* Use flexbox for layout */
    gap: 10px;          /* Space between input and button */
    margin-top: 15px;   /* Space above the form */
    align-items: center; /* Align items vertically if needed */
}

/* Style the specific command input field */
#command-input {
flex-grow: 1;     /* Allow the input field to grow and fill available space */
margin-right: 0;  /* Override default right margin if any from general input rules */
min-width: 150px; /* Optional: ensure a minimum width */
padding-top: 3px;    /* Increased top padding */
padding-bottom: 3px; /* Increased bottom padding */
width: 100%;
/* Inherits padding, border, font-size etc. from general input[type="text"] rules */
}

/* Style the send button within this specific form */
.logs-section > form > button#send-button {
    margin-right: 0; /* Override default right margin if any from general button rules */
    flex-shrink: 0; /* Prevent the button from shrinking */
    /* Inherits padding, colors etc. from general button rules */
}
input[type="text"]:disabled { background-color: #e9ecef; }

/* Log Viewer (index.html) */
pre#server-logs { /* Target specific pre */
    background-color: #e9ecef;
    border: 1px solid #ccc;
    padding: 10px;
    max-height: 400px;
    min-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
    font-size: 0.9em;
    margin-bottom: 0px; /* Space before command input */
    text-align: left;
}
pre#server-logs code { display: block; }

/* Auth Forms (login.html, register.html) */
.auth-form {
    max-width: 400px;
    margin: 60px auto 40px auto; /* Adjust top margin for body padding */
    padding: 20px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.auth-form h2 {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: none; /* Remove default border */
}
.auth-form label { display: block; margin-bottom: 5px; font-weight: bold; }
.auth-form input[type="text"],
.auth-form input[type="username"], /* Ensure consistency */
.auth-form input[type="password"] {
    width: 100%; /* Use 100% with box-sizing */
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.auth-form button { width: 100%; padding: 10px 15px; }
.auth-links { text-align: center; margin-top: 15px; }

/* File Manager (file_browser.html) */
.file-manager {
    background-color: #fff;
    padding: 15px 20px;
    margin: 20px auto; /* Center */
    max-width: 1100px; /* Allow wider view */
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.breadcrumbs { margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #eee; font-size: 0.9em; color: #555; }
.breadcrumbs a { text-decoration: none; color: #007bff; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs span { font-weight: bold; color: #333; }
.file-list { width: 100%; border-collapse: collapse; margin-top: 15px; }
.file-list th, .file-list td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #eee; vertical-align: middle; }
.file-list th { background-color: #f8f9fa; font-weight: bold; }
.file-list td a { text-decoration: none; color: #0056b3; font-weight: 500; }
.file-list td a:hover { text-decoration: underline; }
.file-list td span.note { font-size: 0.8em; color: #777; margin-left: 5px; }
.parent-dir { font-weight: bold; }
.file-list td.actions { white-space: nowrap; text-align: right; }
.item-name-display { display: inline; }
.action-buttons { display: inline-block; margin-left: 10px; }

/* File Manager Action Buttons */
.actions .action-button, .clipboard-actions .action-button, .upload-section .action-button, .create-actions .action-button {
    background: none; border: none; padding: 2px 5px; margin: 0 2px; cursor: pointer; font-size: 1.1em; vertical-align: middle; color: #555; display: inline-block;
}
.actions .action-button:hover, .clipboard-actions .action-button:hover, .upload-section .action-button:hover, .create-actions .action-button:hover { color: #000; }
.action-button.delete { color: #dc3545; }
.action-button.delete:hover { color: #a0202d; }
.action-button.rename { color: #007bff; }
.action-button.copy { color: #ffc107; }
.action-button.cut { color: #fd7e14; }
.action-button.paste { color: #28a745; padding: 5px 10px; font-size: 0.9em; background-color: #e9ecef; border-radius: 3px;}
.action-button.clear-clip { color: #6c757d; padding: 5px 10px; font-size: 0.9em; background-color: #e9ecef; border-radius: 3px;}
.action-button.download { color: #17a2b8; }
.action-button.upload { color: white; background-color: #28a745; padding: 5px 10px; font-size: 0.9em; border-radius: 3px;}
.action-button.create-folder { background-color: #ffc107; color: #333; padding: 5px 10px; font-size: 0.9em; border-radius: 3px; border: none; cursor: pointer; }
.action-button.create-folder:hover { background-color: #e0a800; }
.action-button.create-file { background-color: #17a2b8; color: white; padding: 5px 10px; font-size: 0.9em; border-radius: 3px; border: none; cursor: pointer; }
.action-button.create-file:hover { background-color: #117a8b; }

/* Rename Form */
.rename-form { display: inline-block; margin-left: 5px; }
.rename-input { padding: 3px 5px; border: 1px solid #ccc; border-radius: 3px; margin-right: 3px; }
.rename-form .action-button { font-size: 1em; padding: 3px 6px; }
.rename-confirm { color: #28a745; }
.rename-cancel { color: #dc3545; }

/* Upload/Create/Clipboard Sections */
.upload-section, .create-actions, .clipboard-actions {
    margin-bottom: 15px; padding: 10px; background-color: #f8f9fa; border: 1px solid #eee; border-radius: 4px;
}
.upload-section label { font-weight: bold; margin-right: 10px; }
.upload-section input[type="file"] { margin-right: 10px; }
.upload-section small { color: #6c757d; margin-left: 15px; font-size: 0.85em; }
.create-actions { display: flex; gap: 20px; flex-wrap: wrap; }
.create-actions form { display: flex; align-items: center; gap: 5px; }
.create-actions label { font-weight: bold; font-size: 0.9em; }
.create-actions input[type="text"] { padding: 5px 8px; border: 1px solid #ccc; border-radius: 3px; font-size: 0.9em; }
.clipboard-actions { font-size: 0.9em; }
.clipboard-actions span { margin-right: 15px; font-style: italic; }

/* File Viewer/Editor (file_viewer.html) */
.file-content-wrapper { /* New wrapper */
    background-color: #fff;
    padding: 15px 20px;
    margin: 20px auto; /* Center */
    max-width: 1000px; /* Adjust width */
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.file-content-wrapper h2 { margin-top: 0;}
textarea#file_content_editor, pre#file_content_viewer code {
    width: 100%; /* Fill container */
    min-height: 60vh;
    font-family: monospace;
    font-size: 0.9em;
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 10px;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    display: block; /* Ensure block display */
}
pre#file_content_viewer { /* Style the pre container */
    background-color: #f8f9fa;
    max-height: 70vh;
    overflow: auto;
}
.save-button-container { margin-top: 15px; text-align: right; }
.save-button-container button { padding: 10px 20px; font-weight: bold; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer; }
.save-button-container button:hover { background-color: #218838; }
.view-only-notice { font-style: italic; color: #666; margin-top: 10px; }

/* Server Properties Editor (server_properties.html) */
.properties-form {
    max-width: 1000px; margin: 20px auto; background-color: #fff; padding: 20px 30px; border: 1px solid #ddd; border-radius: 5px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.properties-form h1 { margin-bottom: 20px; text-align: center; }
.settings-grid { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; }
.properties-form .setting-item { flex: 1 0 calc(33.333% - 14px); width: calc(33.333% - 14px); margin-bottom: 0; padding: 15px; border: 1px solid #eee; border-radius: 4px; }
.properties-form .comment-line, .properties-form .empty-line { flex-basis: 100%; width: 100%; margin-bottom: 10px; padding: 5px 0; }
.properties-form .comment-line { font-family: monospace; color: #666; font-size: 0.9em; white-space: pre-wrap; border-bottom: 1px dashed #eee; }
.properties-form .empty-line { height: 0.5em; }
.properties-form label { display: block; margin-bottom: 8px; font-weight: bold; color: #333; font-family: monospace; word-wrap: break-word; }
.properties-form input[type="text"], .properties-form input[type="number"], .properties-form select { width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.95em; }
.save-button-container { margin-top: 20px; text-align: center; }
.save-button-container.top { margin-bottom: 30px; margin-top: 10px; }
.save-button-container button {
    padding: 12px 25px;
    font-weight: bold;
    font-size: 1.1em;
    cursor: pointer;
    /* ADD THIS LINE TO OVERRIDE THE GENERAL MARGIN: */
    margin-left: 0; /* Explicitly set left */
    margin-right: 0; /* Explicitly set right to 0 to override the general 10px */
    /* Or alternatively, reset all margins: */
    /* margin: 0; */
} button styles apply */ }

/* Error Page (file_error.html) */
.error-container {
    max-width: 600px;
    margin: 40px auto; /* Center */
    padding: 20px;
    /* Minimal styling, relies on general elements */
}
.error-container h2 { /* Optional styling */
    color: #dc3545; text-align: center; border-bottom: none;
}

/* --- General Elements --- */
button {
    padding: 10px 15px; font-size: 1em; cursor: pointer; border: none; border-radius: 4px; color: white; background-color: #007bff; margin-right: 10px; transition: background-color 0.2s ease;
}
button:hover:not(:disabled) { background-color: #0056b3; }
button.stop { background-color: #dc3545; }
button.stop:hover:not(:disabled) { background-color: #c82333; }
button:disabled { background-color: #cccccc; cursor: not-allowed; }

.nav-links { text-align: center; margin-bottom: 20px; }
.nav-links a { text-decoration: none; padding: 5px 10px; background-color: #e9ecef; color: #007bff; border-radius: 4px; font-size: 0.9em; margin: 0 5px; }
.nav-links a:hover { background-color: #dcdfe2; text-decoration: none; }
.main-nav-link { /* Special style from file_browser */ display: block; text-align: center; margin-bottom: 20px; }

.warning, .warning-notice { /* Combined general warning styles */
    color: #856404; background-color: #fff3cd; border: 1px solid #ffeeba; padding: 10px 15px; border-radius: 4px; margin: 15px auto; /* Center */ font-size: 0.9em; max-width: 900px; /* Limit width */ text-align: center;
}


/* --- Dark Mode Styles --- */
body.dark-mode { background-color: #121212; color: #e0e0e0; }
body.dark-mode .theme-toggle-label { color: #bbb; }
body.dark-mode h1, body.dark-mode h2 { color: #bbbbbb; border-bottom-color: #444; }
body.dark-mode .status-section, body.dark-mode .logs-section, body.dark-mode .file-manager, body.dark-mode .file-content-wrapper, body.dark-mode .properties-form, body.dark-mode .auth-form {
    background-color: #1e1e1e; border-color: #333; box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
body.dark-mode button:disabled { background-color: #444; color: #888; border-color: #555; }
body.dark-mode input[type="text"], body.dark-mode input[type="username"], body.dark-mode input[type="password"], body.dark-mode input[type="number"], body.dark-mode select, body.dark-mode textarea {
    background-color: #333; border-color: #555; color: #e0e0e0;
}
body.dark-mode input[type="text"]:disabled { background-color: #2a2a2a; }
body.dark-mode pre#server-logs, body.dark-mode pre#file_content_viewer { background-color: #2a2a2a; border-color: #444; color: #d0d0d0; }
body.dark-mode .toast.success { color: #a3cfbb; background-color: #1a3c26; border-color: #2b6a41; }
body.dark-mode .toast.error { color: #f5c6cb; background-color: #58151c; border-color: #a02b36; }
body.dark-mode .toast.warning { color: #ffeeba; background-color: #665104; border-color: #aa8d0b; }
body.dark-mode .toast.info { color: #bee5eb; background-color: #0b3e46; border-color: #1b7a8a; }
body.dark-mode .breadcrumbs { border-bottom-color: #333; color: #aaa;}
body.dark-mode .breadcrumbs a { color: #6cacf0; }
body.dark-mode .breadcrumbs span { color: #e0e0e0; }
body.dark-mode .file-list th { background-color: #2a2a2a; color: #ccc; }
body.dark-mode .file-list th, body.dark-mode .file-list td { border-bottom-color: #333; }
body.dark-mode .file-list td a { color: #8ab4f8; }
body.dark-mode .file-list td span.note { color: #aaa; }
body.dark-mode .nav-links a { background-color: #333; color: #8ab4f8; }
body.dark-mode .nav-links a:hover { background-color: #444;}
body.dark-mode .warning, body.dark-mode .warning-notice { color: #ffeeba; background-color: #665104; border: 1px solid #aa8d0b;}
body.dark-mode .actions .action-button, body.dark-mode .clipboard-actions .action-button, body.dark-mode .upload-section .action-button, body.dark-mode .create-actions .action-button { color: #bbb; }
body.dark-mode .actions .action-button:hover, body.dark-mode .clipboard-actions .action-button:hover, body.dark-mode .upload-section .action-button:hover, body.dark-mode .create-actions .action-button:hover { color: #eee; }
body.dark-mode .action-button.delete { color: #f48a94; }
body.dark-mode .action-button.delete:hover { color: #e55060; }
body.dark-mode .action-button.rename { color: #6cacf0; }
body.dark-mode .action-button.copy { color: #fdd663; }
body.dark-mode .action-button.cut { color: #ffa75a; }
body.dark-mode .action-button.paste { color: #81c995; background-color: #333; }
body.dark-mode .action-button.clear-clip { color: #aaa; background-color: #333;}
body.dark-mode .action-button.download { color: #78d9ec; }
body.dark-mode .action-button.create-folder { background-color: #fdd663; color: #121212; }
body.dark-mode .action-button.create-folder:hover { background-color: #e0a800; }
body.dark-mode .action-button.create-file { background-color: #78d9ec; color: #121212; }
body.dark-mode .action-button.create-file:hover { background-color: #50c1d8; }
body.dark-mode .rename-input { background-color: #444; border-color: #666; color: #e0e0e0;}
body.dark-mode .rename-confirm { color: #81c995; }
body.dark-mode .rename-cancel { color: #f48a94; }
body.dark-mode .upload-section, body.dark-mode .create-actions, body.dark-mode .clipboard-actions { background-color: #2a2a2a; border-color: #333;}
body.dark-mode .upload-section small { color: #aaa; }
body.dark-mode .clipboard-actions { background-color: #2a2a3a; border-color: #3a3a4a;}
body.dark-mode textarea#file_content_editor { background-color: #1e1e1e; color: #e0e0e0; border-color: #444; }
body.dark-mode .save-button-container button { background-color: #3a9d4a; border-color: #3a9d4a; }
body.dark-mode .save-button-container button:hover { background-color: #2e7b3a; border-color: #2e7b3a; }
body.dark-mode .view-only-notice { color: #aaa; }
body.dark-mode .properties-form .setting-item { border-color: #333; }
body.dark-mode .properties-form label { color: #ccc; }
body.dark-mode .properties-form .comment-line { color: #999; border-bottom-color: #333; }
body.dark-mode .auth-form label { color: #e0e0e0; }
body.dark-mode .error-container h2 { color: #f48a94; }
body.dark-mode .auth-status { color: #bbb; }
body.dark-mode .auth-status a { color: #6cacf0; }
