/* --- Base Styles & Variables --- */
:root {
    /* New Color Palette (Example: Teal/Indigo focus) */
    --primary-color: #4f46e5; /* Indigo */
    --secondary-color: #64748b; /* Slate Gray */
    --success-color: #10b981; /* Emerald Green */
    --danger-color: #ef4444;  /* Red */
    --warning-color: #f59e0b; /* Amber */
    --light-bg: #f8fafc;      /* Very Light Gray */
    --card-bg: #ffffff;       /* White */
    --text-color: #1f2937;    /* Dark Gray/Black */
    --muted-color: #6b7280;   /* Medium Gray */
    --border-color: #e5e7eb;  /* Light Border Gray */

    --font-family: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --box-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.12);
    --padding-card: 24px;
    --margin-card: 24px;
    --transition-speed: 0.2s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Base font size */
}

body {
    font-family: var(--font-family);
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
    direction: rtl;
    padding: var(--margin-card); /* Add padding around the whole body */
}

.container {
    max-width: 1100px; /* Increased max-width */
    margin: 0 auto; /* Center container */
}

/* --- Header --- */
.header {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--margin-card);
    padding-bottom: var(--padding-card);
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    color: var(--primary-color);
    font-size: 1.75rem; /* Responsive font size unit */
    font-weight: 700;
    margin-bottom: 10px; /* Add margin for wrapping */
}

.status {
    display: flex;
    align-items: center;
    font-weight: 500;
    background-color: #e9ecef; /* Light background for status */
    padding: 5px 12px;
    border-radius: var(--border-radius);
    min-width: 110px; /* Ensure some minimum width */
    justify-content: center;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
    display: inline-block;
    transition: background-color var(--transition-speed) ease;
}

.status-indicator.disconnected { background-color: var(--danger-color); }
.status-indicator.connecting { background-color: var(--warning-color); }
.status-indicator.connected { background-color: var(--success-color); }

/* --- Main Content Layout (CSS Grid) --- */
.main-content {
    display: grid;
    /* Define two EQUAL columns for the top row */
    grid-template-columns: 1fr 1fr;
    gap: var(--margin-card);
    /* Remove grid-template-areas if you used it before */
}

/* --- Card Style --- */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: var(--padding-card);
    transition: box-shadow var(--transition-speed) ease;
}
/* Optional: Hover effect for cards */
/* .card:hover { box-shadow: var(--box-shadow-hover); } */

.card h2 {
    margin-bottom: var(--margin-card);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* --- Form Styles --- */
.form-group {
    margin-bottom: 1rem; /* Use rem for scalable spacing */
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--muted-color);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem; /* Adjusted padding */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: var(--font-family);
    background-color: var(--light-bg); /* Slightly off-white inputs */
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg); /* White background on focus */
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); /* Adjusted shadow color */
}

/* --- Action Buttons --- */
.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 12px;
}

.form-actions button {
    flex-grow: 1; /* Make buttons share space */
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700; /* Bolder buttons */
    font-family: var(--font-family);
    text-align: center;
    transition: all var(--transition-speed) ease;
}

.form-actions button:active {
    transform: scale(0.98);
}

.form-actions button#connectBtn {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}
.form-actions button#connectBtn:hover {
    background-color: #4338ca; /* Darker Indigo */
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.form-actions button#disconnectBtn {
    background-color: var(--secondary-color); /* Using secondary for disconnect */
    color: #fff;
    box-shadow: 0 2px 4px rgba(100, 116, 139, 0.2);
}
.form-actions button#disconnectBtn:hover {
    background-color: #475569; /* Darker Slate */
    box-shadow: 0 4px 8px rgba(100, 116, 139, 0.3);
}

.form-actions button:disabled {
    background-color: #cbd5e1; /* Lighter gray when disabled */
    color: var(--secondary-color);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.8;
}

/* --- Message Log Styles --- */
.message-log #messages {
    background-color: #f9fafb; /* Slightly different background */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    min-height: 350px; /* Consistent min-height */
    max-height: 500px; /* Increased max */
    overflow-y: auto;
    padding: 1rem;
    font-size: 0.9rem; /* Smaller font for logs */
    line-height: 1.6;
    color: var(--muted-color);
}

.message-log #messages p {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color); /* Dashed separator */
    word-wrap: break-word;
    /* Consider monospace font for parts of the message if needed */
    /* font-family: 'Courier New', Courier, monospace; */
}

.message-log #messages p:last-child {
    border-bottom: none;
}
/* Style for timestamp (optional) */
.message-log #messages p::before {
    content: attr(data-timestamp) " - "; /* Use a data attribute for timestamp */
    font-weight: 500;
    color: var(--secondary-color);
    font-size: 0.85em;
    margin-left: 5px; /* RTL */
}

.message-log {
    /* Make the message log span across ALL grid columns */
    grid-column: 1 / -1; /* Start at column line 1, end at last column line */

    /* The existing styles for .message-log #messages remain the same */
    /* ... existing background, border, height, overflow etc ... */
}

/* --- Responsive Design --- */
@media (max-width: 992px) { /* Tablet and smaller */
    .main-content {
        /* Stack columns - This already handles the layout correctly */
        grid-template-columns: 1fr;
    }
    /* The grid-column: 1 / -1 on .message-log will still work fine */
    /* ... other responsive rules ... */
}

@media (max-width: 576px) { /* Mobile */
    body {
        padding: 15px; /* Reduce body padding */
    }
    .container {
       padding: 0; /* Remove container padding if body has it */
    }
    .card {
        padding: 1rem; /* Reduce card padding */
    }
     .header h1 {
        font-size: 1.4rem;
    }
    .form-actions {
        flex-direction: column; /* Stack buttons */
    }
    .message-log #messages {
        min-height: 200px;
        max-height: 300px;
        font-size: 0.85rem;
    }
}

/* Add style for textarea */
.form-group textarea {
    width: 100%;
    padding: 10px 12px; /* Match input padding */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: var(--font-family);
    background-color: var(--light-bg);
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    resize: vertical; /* Allow vertical resize only */
    min-height: 80px; /* Minimum height */
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}


/* --- Action Buttons --- */
/* ... (استایل‌های قبلی button) ... */

/* Optional: Style the publish button specifically if needed */
.form-actions button#publishBtn {
     background-color: var(--success-color); /* Example: Green for publish */
     color: #fff;
     box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}
.form-actions button#publishBtn:hover {
     background-color: #059669; /* Darker Emerald */
     box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}
.form-actions button#publishBtn:disabled {
     background-color: #cbd5e1; /* Lighter gray when disabled */
     color: var(--secondary-color);
     cursor: not-allowed;
     box-shadow: none;
     opacity: 0.8;
}

