/* Root variables for consistent theming */
:root {
    --primary: #3A56D9;
    --secondary-bg: #F5F9FE;
    --card-bg: #FFFFFF;
    --text-dark: #333;
    --text-muted: #666;
    --radius: 8px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    /* Danger color used for delete buttons */
    --danger: #E74C3C;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: var(--secondary-bg);
    color: var(--text-dark);
}

.icon-btn { background:transparent; border:none; cursor:pointer; margin-right:8px; }
.attachment-preview { display:flex; gap:6px; flex-wrap:wrap; margin:6px 0; }
.attachment-chip { font-size:.85rem; padding:4px 8px; border:1px solid #ddd; border-radius:12px; }


/* Sidebar styling */
.sidebar {
    width: 240px;
    background: var(--card-bg);
    border-right: 1px solid #E6EAF0;
    display: flex;
    flex-direction: column;
    padding: 20px;
}
.sidebar .logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 30px;
}
.nav {
    list-style: none;
    flex-grow: 1;
}
.nav li {
    margin-bottom: 10px;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}
.nav a:hover,
.nav a.active {
    background-color: var(--secondary-bg);
    color: var(--primary);
}
.nav i {
    font-size: 1rem;
}

/* User profile area at bottom of sidebar */
.user-profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 20px;
}
.user-profile .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(45deg,#7187F1,#A17CF5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
}
.user-profile .info {
    display: flex;
    flex-direction: column;
}
.user-profile .info .name {
    font-weight: 600;
}
.user-profile .info .role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main content area */
.main-content {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
}
.header {
    margin-bottom: 30px;
}
.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Cards grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}
.card .icon {
    font-size: 1.4rem;
    padding: 10px;
    border-radius: 50%;
    color: #fff;
    align-self: flex-start;
}
.card h3 {
    font-size: 1.05rem;
    font-weight: 600;
}
.card p {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}
.card .desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}
/* Specific colors for cards */
.card.leads .icon { background: #C7DFFF; color: #2F56B3; }
.card.deals .icon { background: #D5EBC8; color: #2E7D32; }
.card.contacts .icon { background: #FFEDD2; color: #C37E00; }
.card.tasks .icon { background: #FFD6DC; color: #C2185B; }
.card.files .icon { background: #D1EAFB; color: #2980B9; }
.card.agents .icon { background: #D5EBC8; color: #2E7D32; }
.card.printers .icon { background: #FFE6C4; color: #C37E00; }

/* Table styles */
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    width: 100%;
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead {
    background: var(--secondary-bg);
}
th, td {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.95rem;
}
th {
    font-weight: 600;
    color: var(--text-muted);
}
tr:nth-child(even) {
    background: #FAFBFD;
}
tr:hover {
    background: #F1F5FC;
}
.status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    text-transform: uppercase;
}
.status.open { background: #E6F4EA; color: #2E7D32; }
.status.inprogress { background: #FFF4E5; color: #C37E00; }
.status.closed { background: #FDECEA; color: #C2185B; }

/* Search and filters */
.search-bar {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}
.search-bar input[type="text"],
.search-bar select {
    padding: 10px 12px;
    border: 1px solid #D8DFE8;
    border-radius: var(--radius);
    background: #FFFFFF;
    outline: none;
}
.search-bar input[type="text"]:focus,
.search-bar select:focus {
    border-color: var(--primary);
}
.search-bar button {
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
.search-bar button:hover {
    background: #2F4AB5;
}

/* Form container for login page */
.login-wrapper {
    margin: auto;
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    padding: 40px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.login-wrapper h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    text-align: center;
}
.login-wrapper .form-group {
    margin-bottom: 15px;
}
.login-wrapper label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}
.login-wrapper input[type="text"],
.login-wrapper input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #D8DFE8;
    border-radius: var(--radius);
    outline: none;
}
.login-wrapper input[type="text"]:focus,
.login-wrapper input[type="password"]:focus {
    border-color: var(--primary);
}
.login-wrapper button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}
.login-wrapper button:hover {
    background: #2F4AB5;
}

/* Modal overlay and modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Ensure the file preview modal sits above other modals */
#filePreviewModal.modal-overlay {
    z-index: 1100;
}
.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-width: 480px;
    width: 100%;
    padding: 20px;
}

/* Larger modal variant for detailed view */
.modal.large {
    max-width: 900px;
    width: 90%;
    /* Add a stronger shadow for prominent card effect */
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    /* Increase padding for more breathing room */
    padding: 25px;
}

/* Task detail modal styles */
.task-detail {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
    width: 90%;
    max-width: 1000px;
}
/* Header bar for task details */
.task-header {
    background: var(--primary);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.task-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
}
.task-header button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}
/* Content wrapper for main and side columns */
.task-content {
    display: flex;
    flex-direction: row;
    background: var(--card-bg);
    border-radius: 0 0 var(--radius) var(--radius);
}
.task-main {
    flex: 2;
    padding: 24px;
}
.task-side {
    flex: 1;
    background: #F5F7FA;
    padding: 24px;
    border-left: 1px solid #E6EAF0;
    border-radius: 0 0 var(--radius) var(--radius);
}
/* Status header in side panel */
.status-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 18px;
}
.side-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.side-info .info-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}
.side-info .info-item .label {
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 8px;
}
.side-participants {
    margin-top: 24px;
}
.side-participants h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-dark);
}
.side-participants .participant {
    display: flex;
    align-items: center;
    gap: 10px;
}
.side-participants .participant .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}
.side-participants .participant .name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
}
/* Sections inside task main area */
.task-section {
    margin-bottom: 28px;
}
.description-content {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-dark);
    /* Limit the height of the description area in the task details modal and allow scrolling */
    max-height: 240px;
    overflow-y: auto;
    padding-right: 6px; /* space for scrollbar */
}
.task-section:last-child {
    margin-bottom: 0;
}
.task-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.task-section p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-dark);
}
/* File input spacing in attachments/comments */
.task-section input[type="file"] {
    margin-top: 6px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Increase heading sizes and spacing inside large modals */
.modal.large .modal-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
}

/* Add spacing between sections in task details */
.attachments-section,
.comments-section {
    margin-top: 15px;
}
.modal-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
}
.modal-header button {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    /* Use muted color for close icon */
    color: var(--text-muted);
    cursor: pointer;
}
.modal-body .form-group {
    margin-bottom: 15px;
}
.modal-body label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="date"],
.modal-body select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #D8DFE8;
    border-radius: var(--radius);
    background: #fff;
}

/* Style for textarea fields in modals */
.modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #D8DFE8;
    border-radius: var(--radius);
    background: #fff;
    resize: vertical;
    font-family: inherit;
    font-size: 0.95rem;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}
.modal-footer button {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.modal-footer .cancel {
    background: #E6EAF0;
    color: var(--text-dark);
}
.modal-footer .submit {
    background: var(--primary);
    color: #fff;
}
.modal-footer .cancel:hover {
    background: #D8DFE8;
}

/* Generic button style for anchors (used in preview modal) */
.btn {
    background: var(--primary);
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
}
.btn:hover {
    opacity: 0.9;
}

/* Small icon buttons used in file cards */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: background 0.2s;
}
.btn-icon:hover {
    background: #F0F2F8;
}
/* Ensure icons inside icon buttons are visible and inherit the parent color */
.btn-icon i {
    font-size: 1rem;
    line-height: 1;
    color: inherit;
    pointer-events: none;
}

/* File manager action buttons (View, Download, Delete, Print) */
.file-action-btn {
    border-radius: var(--radius);
    font-weight: 500;
    transition: background 0.15s;
}
.file-action-btn:hover {
    background: #F5F7FA;
}

/* Details section within task details modal */
.details-section p {
    margin-bottom: 4px;
    font-size: 0.95rem;
}

/* Attachments list styling */
.attachment-list {
    list-style: none;
    padding-left: 0;
    margin: 10px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.attachment-list li {
    background: #F5F7FA;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Comment list styling */
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Constrain the height of the comments list so it doesn't grow beyond the modal. */
    max-height: 240px;
    overflow-y: auto;
}

/* === Chat Page Styles === */
/* Layout container for chat page */
.chat-container {
    display: flex;
    border: 1px solid #E6EAF0;
    background: var(--card-bg);
    border-radius: var(--radius);
    height: calc(100vh - 180px);
}
/* Sidebar user list */
.chat-users {
    width: 30%;
    border-right: 1px solid #E6EAF0;
    padding: 15px;
    overflow-y: auto;
}
.chat-users input {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #E6EAF0;
    border-radius: var(--radius);
}
.chat-users ul {
    list-style: none;
}
.chat-users li {
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s;
}
.chat-users li:hover,
.chat-users li.active {
    background: var(--secondary-bg);
}
/* Main chat window */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.chat-header {
    padding: 15px;
    border-bottom: 1px solid #E6EAF0;
    background: var(--secondary-bg);
}
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}
.chat-message {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    max-width: 70%;
}
.chat-message.sent {
    align-self: flex-end;
    text-align: right;
}
.chat-message .bubble {
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    margin-bottom: 4px;
}
.chat-message.sent .bubble {
    background: var(--secondary-bg);
    color: var(--text-dark);
}
.chat-message .time {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #E6EAF0;
}
.chat-input textarea {
    flex: 1;
    resize: none;
    padding: 8px;
    border: 1px solid #E6EAF0;
    border-radius: var(--radius);
    margin-right: 8px;
    font-family: inherit;
}
.chat-input button {
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}
.chat-input button:hover {
    background: #2F45B8;
}

/* Invoice modal simple table styles */
.simple-table th,
.simple-table td {
    padding: 6px 8px;
    text-align: left;
}
.simple-table input[type='number'] {
    width: 80px;
}
.btn-secondary {
    background: var(--secondary-bg);
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid #E6EAF0;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}
.btn-secondary:hover {
    background: #EDF2FA;
}
.comment {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #F5F7FA;
    padding: 12px;
    border-radius: var(--radius);
}
.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}
.comment-content {
    flex: 1;
}
.comment-content .comment-author {
    font-weight: 600;
}
.comment-content .comment-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.comment-content .comment-text {
    margin-top: 4px;
    white-space: pre-wrap;
    font-size: 0.95rem;
}
.comment-content .images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    margin-top: 8px;
}
.comment-content .images-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
}

/* Comment form styling */
.comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

/* File chip styling for attachments and comment files */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F5F7FA;
    border: 1px solid #D8DFE8;
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 0.9rem;
    color: var(--text-dark);
    text-decoration: none;
    cursor: pointer;
    margin-right: 6px;
    margin-bottom: 6px;
}
.file-chip i {
    color: var(--primary);
}
.file-chip:hover {
    background: #EFF3FA;
}

/* Comment files container to wrap chips */
.comment-files {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.comment-form textarea {
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid #D8DFE8;
    resize: vertical;
    min-height: 80px;
    font-size: 0.95rem;
}
.comment-form input[type="file"] {
    font-size: 0.9rem;
}
.comment-form button {
    align-self: flex-start;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.comment-form button:hover {
    opacity: 0.9;
}

/* Add spacing above file inputs in attachments and comments */
.attachments-section input[type="file"],
.comments-section input[type="file"] {
    margin-top: 6px;
}
.modal-footer .submit:hover {
    background: #2F4AB5;
}

/* Tasks page attachments and comments */
.attachments-section ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
.attachments-section ul li {
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-dark);
}
.comments-section .comment {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #D8DFE8;
    border-radius: var(--radius);
    background: #FAFBFD;
}
.comments-section .comment .comment-author {
    font-weight: 600;
    margin-bottom: 4px;
}
.comments-section .comment .comment-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.comments-section .comment img {
    max-width: 100%;
    margin-top: 5px;
    border-radius: var(--radius);
}

/* Action buttons in tasks table */
.action-btn {
    padding: 4px 10px;
    margin-right: 6px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-block;
}
.action-btn.edit {
    background: #F4B400;
}
.action-btn.view {
    background: var(--primary);
}
.action-btn:hover {
    opacity: 0.9;
}

/* Layout for task details modal with two columns */
.details-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    flex-wrap: wrap;
}
.details-container .left-column {
    flex: 2;
    min-width: 300px;
}
.details-container .right-column {
    flex: 1;
    min-width: 200px;
    background: #F5F7FA;
    border-radius: var(--radius);
    padding: 20px;
    /* Give the side panel a subtle shadow to lift it from background */
    box-shadow: var(--shadow-sm);
}
.description-section h4 {
    margin-bottom: 6px;
}
.description-section p {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 20px;
}

/* Comment attachments list */
.comment-attachments {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.comment-attachments li {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dark);
}
.comment-attachments li .file-size {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* === Workflow Board Styles === */
.board-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.board-column {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    width: 280px;
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.board-column h3 {
    margin: 0;
    padding: 10px;
    font-size: 1rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    text-align: center;
}

.board-list {
    list-style: none;
    padding: 10px;
    margin: 0;
    flex-grow: 1;
    min-height: 100px;
}

.board-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    user-select: none;
}

.board-card .card-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.board-card .card-assigned,
.board-card .card-due {
    font-size: 0.75rem;
    color: var(--text-muted);
}


/* logout button styling */
.logout-link{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  padding:.5rem 1rem;
  border-radius:9999px;
  border:1px solid #2a2f3a;
  color:#9aa3b2;
  text-decoration:none;
  background:transparent;
}
.logout-link:hover{
  color:#ffffff;
  background:#1b2230;
  border-color:#3a4152;
}
.logout-link i{ font-size: 0.95em; }
