/* --- THEME VARIABLES --- */
:root {
    --bg-color: #f4f4f4;
    --container-bg: #ffffff;
    --section-bg: #f9f9f9;
    --text-color: #333;
    --text-color-light: #666;
    --header-color: #0056b3;
    --border-color: #ddd;
    --input-border-color: #ccc;
    --table-header-bg: #007bff;
    --table-header-text: #ffffff;
    --table-row-even-bg: #f2f2f2;
    --modal-bg: #fefefe;
    --modal-overlay: rgba(0,0,0,0.4);
    --status-danger-bg: #ffcccc;
    --status-warning-bg: #fffacd;
    --status-ok-bg: #d4edda;
    --icon-color: #555;
    --icon-hover-color: #0056b3;
    --nav-tab-bg: #e9ecef;
    --nav-tab-active-bg: #007bff;
}

/* New "Slate" Dark Theme */
body.dark-mode {
    --bg-color: #0d1117;
    --container-bg: #161b22;
    --section-bg: #21262d;
    --text-color: #c9d1d9;
    --text-color-light: #8b949e;
    --header-color: #58a6ff;
    --border-color: #30363d;
    --input-border-color: #484f58;
    --table-header-bg: #1f6feb;
    --table-header-text: #f0f6fc;
    --table-row-even-bg: #1a1f27;
    --modal-bg: #161b22;
    --modal-overlay: rgba(22, 27, 34, 0.8);
    --status-danger-bg: #490202;
    --status-warning-bg: #4b3800;
    --status-ok-bg: #1c3d23; /* Dark Green for OK status */
    --icon-color: #8b949e;
    --icon-hover-color: #58a6ff;
    --nav-tab-bg: #21262d;
    --nav-tab-active-bg: #1f6feb;
}


/* General body and container styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 115%;
    transition: background-color 0.3s, color 0.3s;
}

/* --- Login View --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}
#loginForm {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
#loginForm h2 {
    text-align: center;
    color: var(--header-color);
    margin-top: 0;
    margin-bottom: 25px;
}
#loginForm input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--input-border-color);
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1em;
    background-color: var(--bg-color);
    color: var(--text-color);
}
#loginForm button {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
}
#loginForm button:hover {
    background-color: #0056b3;
}


/* --- Toast Notification Container --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 15px 20px;
    border-radius: 5px;
    color: white;
    font-size: 1em;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success { background-color: #28a745; }
.toast.error { background-color: #dc3545; }

.container {
    max-width: 95%;
    margin: 0 auto;
    background: var(--container-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    transition: background-color 0.3s;
}

/* --- Header Bar for Title and Controls --- */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    color: var(--header-color);
    margin: 0;
    font-size: 2.2em;
}

.top-right-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* --- Theme Toggle & Logout Buttons --- */
.theme-toggle-button, .logout-button, .hamburger-button {
    background: none;
    border: none;
    font-size: 1.6em;
    color: var(--icon-color);
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
}
.theme-toggle-button:hover, .logout-button:hover, .hamburger-button:hover {
    color: var(--icon-hover-color);
    transform: scale(1.1);
}
.hamburger-button {
    display: none; /* Hidden on desktop */
}


/* --- Notification Area Styles --- */
.notification-area {
    position: relative;
}

.notification-button {
    background: none;
    border: none;
    font-size: 1.8em;
    color: var(--icon-color);
    cursor: pointer;
    position: relative;
    padding: 5px;
    transition: color 0.2s;
}

.notification-button:hover {
    color: var(--icon-hover-color);
}

.badge {
    position: absolute;
    top: -5px;
    right: -10px;
    padding: 3px 7px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    font-size: 0.5em;
    font-weight: bold;
    display: none;
}

.badge.show {
    display: block;
}

/* --- Notification Modal --- */
#notificationModal .modal-content {
    max-width: 600px;
}

#notificationList {
    list-style-type: none;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

#notificationList li {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

#notificationList li:last-child {
    border-bottom: none;
}

#notificationList .icon {
    font-size: 1.2em;
}
#notificationList .status-danger .icon { color: #dc3545; }
#notificationList .status-warning .icon { color: #ffc107; }

/* --- Navigation and View Styles --- */
.nav-tabs {
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
}
.nav-tab {
    padding: 10px 20px;
    border: none;
    background-color: var(--nav-tab-bg);
    cursor: pointer;
    font-size: 1.1em;
    border-radius: 5px 5px 0 0;
    color: var(--text-color-light);
}
.nav-tab.active {
    background-color: var(--nav-tab-active-bg);
    color: white;
}
.view {
    display: none;
}
.view.active-view {
    display: block;
}

/* --- Dashboard Styles --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.dashboard-card {
    background-color: var(--section-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.dashboard-card h3 {
    margin-top: 0;
    color: var(--text-color-light);
}
.dashboard-card p {
    font-size: 2em;
    font-weight: bold;
    margin: 0;
    color: var(--header-color);
}

.chart-container {
    background-color: var(--section-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

/* --- Action Button Styles --- */
.mobile-menu-toggle {
    display: none; /* Hidden on desktop */
}
.add-client-button-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 25px;
    padding-top: 10px;
}

.main-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
    max-width: 240px;
    padding: 12px 15px;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.0em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.main-action-button:hover {
    transform: translateY(-1px);
}

.main-action-button {
    background-color: #28a745;
}
.main-action-button:hover {
    background-color: #218838;
}

.main-action-button.secondary {
    background-color: #6c757d;
}
.main-action-button.secondary:hover {
    background-color: #5a6268;
}

body.dark-mode .main-action-button.secondary {
    background-color: var(--section-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
body.dark-mode .main-action-button.secondary:hover {
    background-color: #30363d;
}

.delete-all-button {
    padding: 8px 15px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: background-color 0.2s;
}

.delete-all-button:hover {
    background-color: #c82333;
}

.delete-all-button i {
    margin-right: 5px;
}


/* Table List Section */
.client-list-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--section-bg);
    transition: background-color 0.3s, border-color 0.3s;
}

/* --- Toolbar for search bar and title --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.client-list-title {
    margin: 0;
    flex-shrink: 0;
}

#searchInput {
    padding: 10px 15px;
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    font-size: 1em;
    width: 400px;
    max-width: 100%;
    background-color: var(--container-bg);
    color: var(--text-color);
    box-sizing: border-box; /* Ensures padding doesn't add to width */
}

.last-updated-status {
    font-size: 0.8em;
    color: var(--text-color-light);
    flex-shrink: 0;
}


/* --- Table container for spinner positioning --- */
.table-container {
    position: relative;
    overflow-x: auto;
    min-height: 400px; /* Ensures the container has a minimum height */
}


/* --- Loading Spinner --- */
.spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border: 8px solid rgba(0, 0, 0, 0.1);
    border-left-color: #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 50;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* Table Styles */
table {
    width: 100%; 
    border-collapse: collapse;
    margin: 0;
    white-space: nowrap;
}

table th, table td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
    vertical-align: top;
    font-size: 0.95em;
}

/* Dark mode table border removal */
body.dark-mode table th, body.dark-mode table td {
    border: none;
}
body.dark-mode table th {
    border-bottom: 1px solid var(--border-color);
}

table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* --- Styles for notes truncation --- */
.notes-cell {
    max-width: 200px; /* Adjust width as needed */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* --- Styles for Sortable Headers --- */
table th[data-column] {
    cursor: pointer;
    user-select: none;
}

table th[data-column]:hover {
    background-color: #0056b3;
}
body.dark-mode table th[data-column]:hover {
    background-color: #3c97e8;
}


/* Accessibility: Style for ARIA sort attributes */
table th[aria-sort="ascending"]::after { content: " ▲"; }
table th[aria-sort="descending"]::after { content: " ▼"; }


/* --- ΔΙΟΡΘΩΣΗ: Εφαρμογή μόνο στον πίνακα πελατών --- */
#clientTable td:first-child {
    position: sticky;
    left: 0;
    background-color: var(--container-bg);
    z-index: 9;
}
#clientTable tr:nth-child(even) td:first-child {
    background-color: var(--table-row-even-bg);
}

table tr:nth-child(even) {
    background-color: var(--table-row-even-bg);
}

.actions {
    /* This will be handled in the media query for mobile */
}

.actions button {
    padding: 6px 12px;
    margin-right: 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
    margin-bottom: 6px;
}

.actions .edit-button { background-color: #ffc107; color: #333; }
.actions .edit-button:hover { background-color: #e0a800; }
.actions .delete-button { background-color: #dc3545; color: white; }
.actions .delete-button:hover { background-color: #c82333; }
.actions .email-reminder-btn {
    background-color: #17a2b8;
    color: white;
}
.actions .email-reminder-btn:hover {
    background-color: #138496;
}


/* Modal for editing / adding */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--modal-overlay);
}

.modal-content {
    background-color: var(--modal-bg);
    margin: 8% auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    position: relative;
    box-sizing: border-box;
}


.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    text-align: left;
    margin-top: 0;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-content form label {
    font-weight: bold;
    font-size: 0.9em;
    color: var(--text-color-light);
    margin-bottom: -8px;
}

.modal-content form input,
.modal-content form select,
.modal-content form textarea { /* Added textarea */
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    font-size: 1em;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--input-border-color);
    border-radius: 4px; /* Added for consistency */
}
.modal-content form textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-content button {
    align-self: flex-end;
    padding: 10px 20px;
    font-size: 1em;
}

.date-display-helper {
    font-size: 0.85em;
    color: var(--text-color-light);
    margin-left: 10px;
    font-style: italic;
}

/* --- Management Modal Styles (Hosting & Resellers) --- */
.management-list {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}
.management-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}
.management-list li:last-child {
    border-bottom: none;
}
.management-list .item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    margin-left: 8px;
}
.management-list .edit-item-btn { color: #ffc107; }
.management-list .delete-item-btn { color: #dc3545; }

.add-item-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.add-item-form input {
    flex: 1;
}
.add-item-form button {
    flex-shrink: 0;
}


/* --- Settings & Template Modal Styles --- */
#emailSettingsModal .modal-content, #emailTemplateModal .modal-content {
    max-width: 700px;
}
.template-editor {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.template-editor:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.template-editor h4 {
    margin-top: 0;
}
.template-editor label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-color-light);
}
.template-editor input, .template-editor textarea {
    width: 100%;
    margin-bottom: 10px;
}
.template-placeholders {
    font-size: 0.8em;
    color: var(--text-color-light);
    margin-top: 10px;
}
.template-placeholders code {
    background-color: var(--section-bg);
    padding: 2px 4px;
    border-radius: 3px;
}
.template-chooser-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.template-chooser-list button {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    text-align: left;
    align-self: center; /* Overrides form button style */
}

/* --- Log Table Styles --- */
.log-status-success {
    color: #28a745;
    font-weight: bold;
}
.log-status-failed {
    color: #dc3545;
    font-weight: bold;
}


/* --- Styling based on combined status --- */
table tr.status-danger td {
    background-color: var(--status-danger-bg);
}
table tr.status-warning td {
    background-color: var(--status-warning-bg);
}
table tr.status-ok td {
    background-color: var(--status-ok-bg);
}

/* Override for sticky column background */
#clientTable tr.status-danger td:first-child {
    background-color: var(--status-danger-bg);
}
#clientTable tr.status-warning td:first-child {
    background-color: var(--status-warning-bg);
}
#clientTable tr.status-ok td:first-child {
    background-color: var(--status-ok-bg);
}

/* --- Pagination Controls --- */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}
.pagination-controls .page-buttons button {
    padding: 8px 12px;
    margin: 0 2px;
    border: 1px solid var(--input-border-color);
    background-color: var(--container-bg);
    color: var(--text-color);
    cursor: pointer;
}
.pagination-controls .page-buttons button.active {
    background-color: var(--nav-tab-active-bg);
    color: white;
    border-color: var(--nav-tab-active-bg);
}
.pagination-controls .rows-per-page select {
    padding: 8px;
}


/* --- Media Queries for responsiveness --- */
@media (min-width: 1200px) {
    #dashboardView.active-view { /* Apply grid only when active */
        display: grid;
        grid-template-columns: 300px 1fr;
        gap: 30px;
        align-items: stretch;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-bottom: 0;
    }
}


@media (max-width: 768px) {
    body { padding: 15px; font-size: 100%; }
    .container { padding: 20px; }

    #clientListView .client-list-section {
        padding-left: 10px;
        padding-right: 10px;
    }

    .nav-tabs {
        gap: 4px;
    }
    .nav-tab {
        flex-grow: 1;
        text-align: center;
    }

    .toolbar { 
        flex-direction: column; 
        align-items: stretch; 
    }
    .header-bar { flex-direction: column; align-items: flex-start; gap: 15px; }
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.4em; }
    table th, table td { padding: 8px; font-size: 0.85em; }
    .modal-content { width: 90%; margin: 10% auto; }

    /* --- Mobile Menu Styles --- */
    .mobile-menu-toggle {
        display: block; /* Show hamburger on mobile */
        text-align: center;
        margin-bottom: 15px;
    }
    .mobile-menu-toggle .main-action-button {
        width: 100%;
        max-width: none;
    }
    .add-client-button-container {
        display: none; /* Hide button group by default on mobile */
        flex-direction: column;
        gap: 10px;
    }
    .add-client-button-container.mobile-menu-open {
        display: flex; /* Show when toggled */
    }
    .add-client-button-container .main-action-button {
        width: 100%;
        max-width: none; /* Allow buttons to take full width */
        margin: 0;
    }

    /* --- MOBILE STICKY COLUMN FIXES --- */
    .actions {
        white-space: nowrap;
    }

    /* Hide the ID column on mobile */
    #clientTable th:first-child,
    #clientTable td:first-child {
        display: none;
    }

    /* Make the Website column (now the first visible) sticky */
    #clientTable th:nth-child(2) {
        position: sticky;
        left: 0;
        z-index: 11; /* Higher z-index for header */
        background-color: var(--table-header-bg); /* Use header background */
    }
    #clientTable td:nth-child(2) {
        position: sticky;
        left: 0;
        z-index: 9;
        background-color: var(--container-bg); /* Default background */
    }
    
    /* Ensure correct background for alternating and status rows */
    #clientTable tr:nth-child(even) td:nth-child(2) {
        background-color: var(--table-row-even-bg);
    }
    #clientTable tr.status-danger td:nth-child(2) {
        background-color: var(--status-danger-bg);
    }
    #clientTable tr.status-warning td:nth-child(2) {
        background-color: var(--status-warning-bg);
    }
    #clientTable tr.status-ok td:nth-child(2) {
        background-color: var(--status-ok-bg);
    }
}

@media (max-width: 480px) {
    body { padding: 10px; font-size: 95%; }
    .container { padding: 15px; }

    #clientListView .client-list-section {
        padding-left: 5px;
        padding-right: 5px;
    }

    h1 { font-size: 1.5em; }
    h2 { font-size: 1.2em; }
    table th, table td { padding: 6px; font-size: 0.8em; }
    
    .actions button { 
        display: inline-block; 
        width: auto; 
        margin-right: 5px; 
        margin-bottom: 0; 
    }
    .actions button:last-child {
        margin-right: 0;
    }

    .modal-content { width: 95%; margin: 5% auto; padding: 15px; }
}

