/* Base styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    width: 100%;
}

h1 {
    background-color: #4CAF50;
    color: white;
    padding: 20px 0;
    margin: 0;
    text-align: center;
}

/* Form styles */
form {
    margin: 20px auto;
    padding: 10px;
    max-width: 400px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: .5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: .5rem;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out;
}

.form-group input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    border: 1px solid #1e90ff;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Button styles */
button {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin: 5px 0;
}

button:hover {
    background-color: #45a049;
}

.btn {
    display: inline-block;
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: .25rem;
    transition: all .15s ease-in-out;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

/* Error messages */
.error {
    color: red;
    text-align: center;
    margin-bottom: 10px;
}

.error-message {
    color: #dc3545;
    padding: .5rem;
    margin: .5rem 0;
    border: 1px solid #dc3545;
    border-radius: .25rem;
    background-color: #f8d7da;
}

/* Status indicators */
.status {
    margin-top: 20px;
    text-align: center;
    font-weight: bold;
}

.status-indicator {
    display: inline-block;
    padding: .25rem .5rem;
    border-radius: .25rem;
    font-weight: 500;
}

.status-on {
    color: #28a745;
}

.status-off {
    color: #dc3545;
}

.status-error {
    color: #856404;
    background-color: #fff3cd;
}

ul {
    list-style: none;
    padding: 0;
}

li {
    margin: 10px 0;
    padding: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.device-status {
    margin: 10px 0;
    padding: 8px;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.status-on {
    color: #28a745;
    font-weight: bold;
}

.status-off {
    color: #dc3545;
    font-weight: bold;
}

.status-error {
    color: #856404;
    background-color: #fff3cd;
    padding: 5px;
    border-radius: 4px;
}

.status-unknown {
    color: #6c757d;
    font-weight: bold;
}

.last-update {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

.logout-form {
    margin-top: 30px;
    text-align: right;
}

.timer-section {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-section input {
    width: 80px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.schedule-section {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.days-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.days-selection label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.log-viewer {
    margin-top: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    background-color: #f8f9fa;
}

.log-viewer h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
}

.log-content {
    max-height: 150px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.4;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #888 #f8f9fa;
}

.log-content::-webkit-scrollbar {
    width: 6px;
}

.log-content::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.log-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #eee;
    transition: opacity 0.3s ease;
}

.log-entry:last-child {
    border-bottom: none;
}

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

.device-header h3 {
    margin: 0;
    flex-grow: 1;
    padding-right: 10px;
}

.btn-edit {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-edit:hover {
    background-color: #f0f0f0;
}

.name-edit {
    margin: 10px 0;
}

.name-edit input {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.edit-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.ip-info {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 0.9em;
    color: #666;
}

.devices-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.device-card {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Section header styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin: 0;
    color: #333;
}

/* Responsive grid layout */
@media (max-width: 1200px) {
    .devices-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .devices-list {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}