/* style.css */
/* ---- GLOBAL RESETS & DEFAULTS ---- */
:root {
    --primary-color: #007bff; /* Bootstrap Blue - vibrant and professional */
    --primary-hover-color: #0056b3;
    --secondary-color: #6c757d; /* Bootstrap Gray - for less prominent actions */
    --secondary-hover-color: #545b62;
    --success-color: #28a745; /* Green */
    --danger-color: #dc3545;  /* Red */
    --warning-color: #ffc107; /* Yellow */
    --info-color: #17a2b8;    /* Teal */
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --text-color: #212529;
    --text-muted-color: #6c757d;
    --border-color: #dee2e6;
    --background-color: #fff;
    --accent-color-project: #3498db; /* Default project accent */

    --font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --border-radius: 0.25rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 1rem 3rem rgba(0,0,0,.175);

    --header-height: 60px;
    --sidebar-width: 250px;
    --custom-links-bar-height: 30px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: calc(var(--header-height) + var(--custom-links-bar-height)); /* Space for fixed header & links bar */
}

a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--primary-hover-color); text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin-top: 0; margin-bottom: 0.75rem; font-weight: 500; line-height: 1.2; color: var(--dark-color); }
h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
p { margin-top: 0; margin-bottom: 1rem; }
ul, ol { padding-left: 20px; margin-top: 0; margin-bottom: 1rem; }
img { vertical-align: middle; border-style: none; }
label { display: inline-block; margin-bottom: 0.5rem; font-weight: 500;}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---- LAYOUT ---- */
.custom-links-bar {
    background-color: #e9ecef;
    padding: 5px 15px;
    font-size: 0.85em;
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: var(--custom-links-bar-height);
    z-index: 1025; /* Below header, above content */
    overflow-x: auto;
    white-space: nowrap;
}
.custom-links-bar a { margin-right: 15px; color: var(--secondary-color); }
.custom-links-bar a:hover { color: var(--dark-color); }
.custom-links-bar .manage-links-btn { float: left; margin-right: 0; margin-left: 10px; padding: 2px 5px; }
.custom-links-bar i { margin-right: 3px; }


header {
    background-color: var(--dark-color);
    color: #fff;
    padding: 0 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--box-shadow);
}
header h1 { margin-bottom: 0; font-size: 1.5rem; }
header h1 a { color: #fff; }
header nav { display: flex; align-items: center; }
header nav a.nav-item, header nav .nav-item {
    color: #f8f9fa;
    padding: 0.5rem 0.75rem;
    margin-left: 0.5rem;
    border-radius: var(--border-radius);
    transition: background-color 0.2s ease;
}
header nav a.nav-item:hover, header nav .nav-item:hover,
header nav a.nav-item:focus, header nav .nav-item:focus {
    background-color: rgba(255,255,255,0.1);
    text-decoration: none;
}
header nav .username-display { font-weight: 500; }
header nav form button { background: none; border: none; color: #f8f9fa; cursor: pointer; padding: 0.5rem 0.75rem;}
header nav form button:hover { background-color: rgba(255,255,255,0.1); }

.search-form { display: flex; align-items: center; margin-right: 1rem; }
.search-form input[type="search"] {
    padding: 0.375rem 0.75rem;
    font-size: 0.9rem;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    border: 1px solid var(--border-color);
    border-right: none;
    background-color: #fff;
    color: var(--text-color);
    max-width: 200px;
}
.search-form button {
    padding: 0.375rem 0.75rem;
    font-size: 0.9rem;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    border: 1px solid var(--primary-color);
    background-color: var(--primary-color);
    color: #fff;
    cursor: pointer;
}
.search-form button:hover { background-color: var(--primary-hover-color); }

.container-wrapper {
    padding-top: 1rem; /* Adjusted as body padding-top covers fixed header+links bar */
}
.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    min-height: calc(100vh - var(--header-height) - var(--custom-links-bar-height) - 70px); /* 70px for footer+padding */
}

.main-content {
    display: flex;
    gap: 1.5rem;
}
.sidebar {
    flex: 0 0 var(--sidebar-width);
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    align-self: flex-start; /* Stick to top */
}
.sidebar h3 { font-size: 1.1rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.sidebar ul { list-style: none; padding: 0; }
.sidebar ul li a { display: block; padding: 0.4rem 0.6rem; border-radius: var(--border-radius); margin-bottom: 0.25rem; }
.sidebar ul li a:hover, .sidebar ul li.active a { background-color: var(--primary-color); color: #fff; text-decoration: none; }
.sidebar #onlineUsersList li i { color: var(--success-color); font-size: 0.7em; }


.content-area { flex: 1; min-width: 0; /* Prevent flex item from overflowing */ }

footer {
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.9em;
    color: var(--text-muted-color);
    border-top: 1px solid var(--border-color);
}

/* ---- ALERTS ---- */
.alert {
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
}
.alert-success { color: #155724; background-color: #d4edda; border-color: #c3e6cb; }
.alert-danger { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
.alert-warning { color: #856404; background-color: #fff3cd; border-color: #ffeeba; }
.alert-info { color: #0c5460; background-color: #d1ecf1; border-color: #bee5eb; }

/* ---- FORMS & BUTTONS ---- */
.form-group { margin-bottom: 1rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="tel"], input[type="url"],
textarea, select {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="number"]:focus, input[type="tel"]:focus, input[type="url"]:focus,
textarea:focus, select:focus {
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}
input[type="color"] { padding: 0.2rem; height: calc(1.5em + 1rem + 2px); }
select[multiple] { height: auto; }
textarea { resize: vertical; }

.btn {
    display: inline-block;
    font-weight: 400;
    color: var(--text-color);
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: var(--border-radius);
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.btn i { margin-right: 0.3em; }

.btn-primary { color: #fff; background-color: var(--primary-color); border-color: var(--primary-color); }
.btn-primary:hover { color: #fff; background-color: var(--primary-hover-color); border-color: var(--primary-hover-color); }
.btn-secondary { color: #fff; background-color: var(--secondary-color); border-color: var(--secondary-color); }
.btn-secondary:hover { color: #fff; background-color: var(--secondary-hover-color); border-color: var(--secondary-hover-color); }
.btn-danger { color: #fff; background-color: var(--danger-color); border-color: var(--danger-color); }
.btn-danger:hover { color: #fff; background-color: #c82333; border-color: #bd2130; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; line-height: 1.5; border-radius: 0.2rem; }

.auth-form {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}
.auth-form h2 { text-align: center; margin-bottom: 1.5rem; }
.auth-error { max-width: 400px; margin-left: auto; margin-right: auto; }

/* ---- MODALS ---- */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 25px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: var(--border-radius);
    position: relative;
    box-shadow: var(--box-shadow-lg);
}
.modal-content h3 { margin-top:0; }
.close-button {
    color: #aaa;
    float: left; /* RTL: float left for close X */
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}
.close-button:hover, .close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* ---- TABS ---- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.tab-button {
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--secondary-color);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px; /* To align with container border */
}
.tab-button.active { color: var(--primary-color); border-bottom-color: var(--primary-color); font-weight: 500; }
.tab-button:hover { color: var(--primary-color); }
.tab-button i { margin-left: 0.4em; } /* RTL: margin-left */

.tab-content { display: none; animation: fadeIn 0.5s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- PROJECT SPECIFIC ---- */
.project-header { padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); }
.project-header h2 small { font-size: 0.8em; color: var(--text-muted-color); }
.project-actions { margin-top: 0.5rem; }
.project-actions .btn, .project-actions form { margin-right: 0.5rem; } /* RTL: margin-right */

/* ---- TASK LIST ---- */
.task-list { list-style: none; padding: 0; }
.task-item {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--secondary-color); /* Default status color */
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: box-shadow 0.2s ease;
}
.task-item:hover { box-shadow: var(--box-shadow); }
.task-details { flex-grow: 1; }
.task-actions { flex-shrink: 0; margin-right: 1rem; /* RTL: margin-right */ }
.task-actions .btn, .task-actions select { margin-bottom: 0.5rem; display: block; width: 100%; }
.task-name { font-weight: 600; font-size: 1.1em; }
.task-progress-indicator { font-size: 0.9em; color: var(--text-muted-color); }
.task-description-preview { font-size: 0.9em; color: var(--text-muted-color); margin: 0.5rem 0; }
.task-item small { font-size: 0.8em; color: #777; display: block; margin-top: 0.3rem; }

.priority-1 { font-weight: bold; color: var(--danger-color); } /* High */
.priority-2 { color: var(--warning-color); } /* Medium */
.priority-3 { color: var(--info-color); } /* Low */

/* Task Status Colors */
.task-status-todo { border-left-color: var(--danger-color); }
.task-status-in-progress { border-left-color: var(--warning-color); }
.task-status-done { border-left-color: var(--success-color); opacity: 0.7; }
.task-status-done .task-name { text-decoration: line-through; }
.task-status-on-hold { border-left-color: var(--secondary-color); }
.task-status-cancelled { border-left-color: #444; opacity: 0.6; }
.task-status-cancelled .task-name { text-decoration: line-through; }

.task-addons { margin-top: 0.75rem; }
.task-addons details { margin-bottom: 0.5rem; }
.task-addons summary { cursor: pointer; font-weight: 500; font-size: 0.9em; color: var(--secondary-color); }
.task-addons summary:hover { color: var(--primary-color); }
.comments-section, .checklist-section {
    background-color: #f9f9f9;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.9em;
}
.comment-item { border-bottom: 1px dashed #ddd; padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
.comment-item:last-child { border-bottom: none; margin-bottom: 0; }
.comment-item p { margin-bottom: 0.25rem; }
.checklist-section ul { list-style: none; padding-left: 0; }
.checklist-section li { margin-bottom: 0.3rem; }
.checklist-section input[type="checkbox"] { margin-left: 0.5rem; vertical-align: middle;} /* RTL */

.highlight-momentarily {
    animation: highlight-bg 2.5s ease-out;
}
@keyframes highlight-bg {
    0% { background-color: rgba(255, 255, 0, 0.5); } /* Light yellow */
    100% { background-color: transparent; }
}

/* ---- FILE LIST & USER LIST & CONTACTS LIST ---- */
.file-list, .user-list, .contacts-list, .search-result-list, .notifications-page-list {
    list-style: none; padding: 0;
}
.file-item, .user-list li, .contact-item, .search-result-list li, .notifications-page-list li {
    background-color: #fff;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.file-item small, .contact-item small { color: var(--text-muted-color); }
.contact-item h4 { margin-bottom: 0.25rem; }
.contact-item p { margin-bottom: 0.2rem; font-size: 0.9em; }
.contact-actions .btn { margin-right: 5px; } /* RTL */

/* ---- NOTIFICATIONS DROPDOWN ---- */
.notifications-dropdown { position: relative; }
.notifications-button { background: none; border: none; color: #f8f9fa; cursor: pointer; position: relative; padding: 0.5rem 0.75rem;}
.notifications-button:hover { background-color: rgba(255,255,255,0.1); }
.notifications-count {
    position: absolute;
    top: 2px;
    left: 2px; /* RTL */
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    padding: 1px 5px;
    font-size: 0.7em;
    font-weight: bold;
    line-height: 1;
}
.notifications-list {
    display: none;
    position: absolute;
    left: 0; /* RTL */
    top: 100%;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    min-width: 300px;
    z-index: 1050;
    max-height: 400px;
    overflow-y: auto;
}
.notifications-list a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    font-size: 0.9em;
    border-bottom: 1px solid var(--border-color);
}
.notifications-list a:last-child { border-bottom: none; }
.notifications-list a:hover { background-color: #f0f0f0; text-decoration: none;}
.notifications-list a.is-read { opacity: 0.7; }
.notifications-list div[role="menuitem"] { /* For "no notifications" message */
    padding: 0.75rem 1rem; color: var(--text-muted-color); font-size: 0.9em;
}

/* ---- DASHBOARD ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}
.dashboard-card {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
}
.dashboard-card h3 { font-size: 1.2rem; margin-bottom: 1rem; }
.dashboard-card ul { padding-left: 1.2rem; font-size: 0.9em; }

/* ---- CALENDAR & GANTT ---- */
#globalCalendar, #projectCalendarProjectView { margin-top: 1rem; }
.fc .fc-button-primary { background-color: var(--primary-color); border-color: var(--primary-color); }
.fc .fc-button-primary:hover { background-color: var(--primary-hover-color); border-color: var(--primary-hover-color); }
.fc-direction-rtl .fc-toolbar.fc-header-toolbar { direction: ltr; } /* Fix FullCalendar header in RTL */
.fc-direction-rtl .fc-toolbar.fc-header-toolbar .fc-toolbar-chunk:first-child { text-align: right; } /* Align title right for RTL */
.fc-direction-rtl .fc-toolbar.fc-header-toolbar .fc-toolbar-chunk:last-child { text-align: left; } /* Align buttons left for RTL */


#ganttChartContainer { min-height: 300px; position: relative; }
#gantt .bar-label { font-size: 12px; fill: #fff; font-weight: 500; }
#gantt .bar-progress { fill: rgba(0,0,0,0.2); }
.gantt-popup { background-color: #fff; border: 1px solid #ccc; padding: 10px; border-radius: 3px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }

/* ---- CHAT INTERFACES ---- */
#projectChatMessagesDisplay, #globalChatMessages {
    border: 1px solid var(--border-color);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    background-color: #f9f9f9;
    overflow-y: auto;
    max-height: 350px; /* Adjust as needed */
}
.chat-message-item {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    background-color: #fff;
    border: 1px solid #eee;
    line-height: 1.4;
}
.chat-message-item.current-user {
    background-color: #e1f5fe; /* Light blue for current user */
    border-color: #b3e5fc;
    margin-right: auto; /* RTL */
    margin-left: 20%; /* RTL */
}
.chat-message-item:not(.current-user) {
    background-color: #f1f1f1; /* Light gray for others */
    border-color: #e0e0e0;
    margin-left: auto; /* RTL */
    margin-right: 20%; /* RTL */
}
.chat-message-item strong { font-weight: 600; }
.chat-message-item small { font-size: 0.8em; color: var(--text-muted-color); }
.chat-message-item p { margin-top: 4px; margin-bottom: 0; word-wrap: break-word; }
.chat-message-item.pending { opacity: 0.7; font-style: italic; }

/* Global Chat Toggle & Panel */
#globalChatToggle {
    position: fixed;
    bottom: 20px;
    left: 20px; /* RTL: left for chat toggle */
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: center;
}
#globalChatToggle:hover { background-color: var(--primary-hover-color); }
.chat-alert-count {
    position: absolute;
    top: -5px;
    right: -5px; /* RTL */
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7em;
    font-weight: bold;
}
#globalChatPanel {
    position: fixed;
    bottom: 80px;
    left: 20px; /* RTL */
    width: 320px;
    max-height: 450px;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    z-index: 1039;
    display: flex;
    flex-direction: column;
    transform: translateY(110%); /* Initially hidden */
    transition: transform 0.3s ease-in-out;
}
#globalChatPanel.open { transform: translateY(0); }
.global-chat-header {
    padding: 10px 15px;
    background-color: var(--dark-color);
    color: white;
    font-weight: 500;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
}
#globalChatMessages { flex-grow: 1; max-height: 350px; }
#globalChatForm { display: flex; padding: 10px; border-top: 1px solid var(--border-color); }
#globalChatForm input[type="text"] { flex-grow: 1; margin-left: 10px; /* RTL */ }

/* ---- TICKET LIST ---- */
.ticket-list { list-style: none; padding: 0; }
.ticket-item {
    background-color: #fff;
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
}
.ticket-item h4 { margin-bottom: 0.5rem; font-size: 1.2em; }
.ticket-item p { margin-bottom: 0.25rem; font-size: 0.9em; }
.ticket-item small { color: var(--text-muted-color); }

.ticket-header { padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); }

/* ---- PHONE BOOK (CONTACTS LIST) ---- */
.contacts-list .contact-actions { margin-top: 0.5rem; }

/* ---- RESPONSIVE ---- */
@media (max-width: 992px) {
    .main-content { flex-direction: column; }
    .sidebar { flex: 0 0 auto; width: 100%; margin-bottom: 1.5rem; }
    .content-area { width: 100%; }
}
@media (max-width: 768px) {
    header { flex-direction: column; height: auto; padding-bottom: 0.5rem; }
    header h1 { margin-bottom: 0.5rem; }
    header nav { flex-wrap: wrap; justify-content: center; }
    header nav a.nav-item, header nav .nav-item { margin-bottom: 0.25rem; }
    body { padding-top: calc(var(--custom-links-bar-height) + 100px); /* Approx dynamic header height */ }
    .custom-links-bar { top: 95px; /* Approx dynamic header height */ }

    .tabs { flex-wrap: wrap; }
    .tab-button { flex-basis: 50%; text-align: center; }

    .modal-content { width: 90%; margin: 10% auto; }
    #globalChatPanel { width: 90%; left: 5%; max-height: 70vh; }
}
@media (max-width: 576px) {
    .task-item { flex-direction: column; }
    .task-actions { width: 100%; margin-top: 0.75rem; margin-right: 0; display: flex; gap: 0.5rem;}
    .task-actions .btn, .task-actions select { width: auto; flex-grow: 1; }
    .search-form input[type="search"] { max-width: 150px; }
}