:root {
    --primary: #3b5998;
    --primary-dark: #2d4373;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --text: #333333;
    --text-light: #6c757d;
    --border: #e1e4e8;
    --hover: #f6f8fa;
    --shadow: rgba(0, 0, 0, 0.1);
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --calendar-bg: #f6f8fa;
    --calendar-border: #e1e4e8;
    --calendar-header: #24292e;
    --calendar-today: #f1f8ff;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base & Common */
body {
    background: var(--bg-light);
    color: var(--text);
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

.card {
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-header {
    background: var(--bg-white);
    color: var(--text);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 16px;
}

.navbar {
    background: var(--primary) !important;
    border-bottom: 1px solid var(--primary-dark) !important;
    height: 56px;
    padding: 0 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: 600;
    color: var(--bg-white) !important;
    font-size: 18px;
}

/* Forms */
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    padding: 8px 12px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 89, 152, 0.25);
}

.form-label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

textarea.form-control,
#new-entry-notes .note-editable,
#edit-entry-notes .note-editable {
    background-color: var(--bg-light) !important;
    color: var(--text) !important;
    font-family: var(--font-family) !important;
    min-height: 100px;
}

/* Buttons */
.btn {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary { background: var(--primary) !important; color: var(--bg-white) !important; border-color: var(--primary) !important; }
.btn-primary:hover { background: var(--primary-dark) !important; }
.btn-success { background: var(--success) !important; color: var(--bg-white) !important; }
.btn-success:hover { background: #218838 !important; }
.btn-danger { background: var(--danger) !important; color: var(--bg-white) !important; }
.btn-danger:hover { background: #c82333 !important; }
.btn-warning { background: var(--warning) !important; color: var(--text) !important; }
.btn-warning:hover { background: #e0a800 !important; }
.btn-info { background: var(--info) !important; color: var(--bg-white) !important; }
.btn-info:hover { background: #138496 !important; }
.btn-light { background: var(--bg-light) !important; color: var(--text) !important; }
.btn-dark { background: #343a40 !important; color: var(--bg-white) !important; }

.btn-outline-primary { background: transparent !important; color: var(--primary) !important; border-color: var(--primary) !important; }
.btn-outline-primary:hover { background: var(--primary) !important; color: var(--bg-white) !important; }

.btn-outline-danger { background: transparent !important; color: var(--danger) !important; border-color: var(--danger) !important; }
.btn-outline-danger:hover { background: var(--danger) !important; color: var(--bg-white) !important; }

.btn-logout, .btn-delete {
    background: var(--danger) !important;
    color: var(--bg-white) !important;
    border-color: var(--danger) !important;
}

.btn-logout:hover, .btn-delete:hover {
    background: #c82333 !important;
}

.task-action-done {
    min-width: 64px;
    height: 36px;
    padding: 0 12px !important;
    background: var(--success) !important;
    border: 1px solid var(--success) !important;
    color: var(--bg-white) !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    transition: all 0.2s !important;
}

.task-action-done:hover {
    background: #218838 !important;
}

.task-action-done:active {
    transform: translateY(1px) !important;
}

/* Badges */
.status-summary-badge,
.badge-enquiry   { background: var(--secondary); color: var(--bg-white); }
.badge-followup  { background: var(--primary); color: var(--bg-white); }
.badge-confirmed { background: var(--success); color: var(--bg-white); }
.badge-lost      { background: var(--danger); color: var(--bg-white); }
.badge-task      { background: var(--warning); color: var(--text); }

.status-summary-badge {
    padding: 6px 12px;
    margin: 4px;
    border-radius: 16px;
    font-weight: 500;
    font-size: 13px;
    display: inline-block;
}

/* Enhanced badges for mobile visibility */
@media (max-width: 768px) {
    .badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
        border-radius: 0.25rem !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        border: 1px solid rgba(0,0,0,0.1) !important;
    }
    
    /* Ensure badge colors are visible on mobile */
    .badge-enquiry {
        background-color: #6c757d !important;
        color: #fff !important;
    }
    
    .badge-followup {
        background-color: #3b5998 !important;
        color: #fff !important;
    }
    
    .badge-confirmed {
        background-color: #28a745 !important;
        color: #fff !important;
    }
    
    .badge-lost {
        background-color: #dc3545 !important;
        color: #fff !important;
    }
    
    .badge-task {
        background-color: #ffc107 !important;
        color: #333 !important;
    }
}

/* Table */
.table {
    background: var(--bg-white);
    border-radius: 6px;
    overflow: hidden;
    font-size: 14px;
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--bg-light);
    color: var(--text);
    font-weight: 600;
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.table-striped tbody tr:nth-of-type(odd) {
    background: var(--bg-light);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 5px;
    flex-wrap: nowrap;
}

.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-width: auto;
    white-space: nowrap;
}

/* Calendar - Simplified Square Design */
#calendar {
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-family: var(--font-family);
}

/* Calendar Header */
.fc-toolbar {
    margin-bottom: 12px !important;
}

.fc-toolbar-title {
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    color: var(--text) !important;
}

.fc-button-group {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 6px !important;
}

.fc-button-primary {
    background: var(--bg-white) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    font-weight: 500 !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    text-transform: capitalize !important;
}

.fc-button-primary:hover {
    background: var(--hover) !important;
}

.fc-button-primary:not(:disabled):active, 
.fc-button-primary:not(:disabled).fc-button-active {
    background: var(--primary) !important;
    color: var(--bg-white) !important;
    border-color: var(--primary) !important;
}

/* Calendar Grid - Square Design */
.fc-daygrid {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: separate !important;
    border-spacing: 2px !important;
}

.fc-daygrid-day-frame {
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 100% !important;
    background: var(--bg-white);
    border: 1px solid var(--calendar-border) !important;
    border-radius: 6px !important;
    overflow: hidden;
    position: relative !important;
    display: block !important;
    cursor: pointer !important; /* Add pointer cursor to indicate clickable */
}

.fc-daygrid-day-frame:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1;
    background-color: var(--hover) !important; /* Add subtle background on hover */
}

.fc-daygrid-day-number {
    color: var(--text) !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    padding: 6px 8px !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 10 !important;
}

.fc-day-today {
    background: var(--calendar-today) !important;
}

.fc-day-today .fc-daygrid-day-number {
    background: var(--primary) !important;
    color: var(--bg-white) !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.fc-day-sat, .fc-day-sun {
    background: var(--calendar-bg) !important;
}

/* Calendar Events - Simplified Design */
.fc-daygrid-day-events {
    position: absolute !important;
    top: 30px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    padding: 4px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    overflow: hidden !important;
}

/* More Events - Centered in cell */
.fc-more-events {
    background: var(--primary) !important;
    color: var(--bg-white) !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    display: inline-block !important;
    text-align: center !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

.fc-more-events:hover {
    background: var(--primary-dark) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Calendar List View - Improved styling */
.fc-list {
    background: var(--bg-white) !important;
    border: 1px solid var(--calendar-border) !important;
    border-radius: 6px !important;
    margin-top: 10px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.fc-list-table {
    font-size: 13px !important;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.fc-list-table thead {
    background: var(--bg-light) !important;
}

.fc-list-table th {
    padding: 10px !important;
    border-bottom: 2px solid var(--calendar-border) !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    text-align: left !important;
}

.fc-list-table td {
    padding: 10px !important;
    border-bottom: 1px solid var(--calendar-border) !important;
    vertical-align: middle !important;
    transition: all 0.2s ease !important;
}

.fc-list-table tr:hover td {
    background-color: var(--hover) !important;
}

.fc-list-heading {
    background: var(--bg-light) !important;
    color: var(--text) !important;
    font-weight: 600 !important;
    padding: 8px 10px !important;
    border-bottom: 2px solid var(--calendar-border) !important;
}

.fc-list-event:hover td {
    background-color: var(--hover) !important;
}

/* Hide "all day" text in list view */
.fc-list-day-cushion .fc-list-day-text {
    margin-right: 0 !important;
}

.fc-list-day-cushion .fc-list-day-side-text {
    display: none !important;
}

/* Calendar Today Button */
#calendar-today-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

#calendar-today-btn.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid var(--bg-white);
    border-radius: 50%;
    border-top-color: transparent;
    border-right-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal */
.modal-content {
    border-radius: 6px;
    border: none;
    background: var(--bg-white);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    background: var(--primary);
    color: var(--bg-white);
    font-weight: 600;
    border-radius: 6px 6px 0 0;
    padding: 16px;
}

/* Loading Spinner */
#loading-spinner {
    z-index: 9999;
}

/* Responsive */
@media (max-width: 768px) {
    .task-action-done {
        min-width: 56px;
        height: 32px;
        font-size: 13px;
    }
    .card-body { padding: 12px; }
    .table th, .table td { padding: 8px; }
    
    .fc-toolbar {
        flex-direction: column !important;
        gap: 8px;
    }
    
    .fc-toolbar-chunk {
        margin-bottom: 8px;
    }
    
    .fc-daygrid-day-frame {
        min-height: 80px !important;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 2px;
    }
    
    .action-buttons .btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Timeline Styles for Activity Log */
.timeline {
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e9ecef;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -24px;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e9ecef;
}

.timeline-content {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    border-left: 3px solid #6c757d;
}

.timeline-item.current .timeline-content {
    border-left-color: var(--primary);
    background: #f0f6ff;
}

.timeline-note {
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.activity-log-preview {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
}

.activity-item {
    font-size: 13px;
}

.activity-item small {
    font-size: 11px;
    font-weight: 600;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.4;
    border-radius: 3px;
}

/* History Note Editor Styles */
.history-note-editor {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
}

.history-note-editor .note-editor {
    min-height: 120px;
}

.history-note-editor .note-toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 5px;
    border-radius: 6px 6px 0 0;
}

.history-note-editor .note-editable {
    background: #fff;
    border: none;
    padding: 10px;
    min-height: 100px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline {
        padding-left: 15px;
    }
    
    .timeline-marker {
        left: -19px;
        width: 12px;
        height: 12px;
    }
    
    .timeline-content {
        padding: 10px;
    }
    
    .history-note-editor {
        padding: 5px;
    }
    
    .history-note-editor .note-editable {
        padding: 5px;
        min-height: 80px;
    }
}

/* Search Section Styles */
#search-input {
    border-right: none;
}

#search-input:focus {
    box-shadow: none;
    border-color: var(--primary);
}

.input-group-text {
    background-color: var(--primary);
    border: 1px solid var(--primary);
    color: white;
}

/* Timeline Styles for Activity Log */
.timeline {
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e9ecef;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -24px;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e9ecef;
}

.timeline-content {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    border-left: 3px solid #6c757d;
}

.timeline-item.current .timeline-content {
    border-left-color: var(--primary);
    background: #f0f6ff;
}

.timeline-note {
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.activity-log-preview {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
}

.activity-item {
    font-size: 13px;
}

.activity-item small {
    font-size: 11px;
    font-weight: 600;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.4;
    border-radius: 3px;
}

/* History Note Editor Styles */
.history-note-editor {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
}

.history-note-editor .note-editor {
    min-height: 120px;
}

.history-note-editor .note-toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 5px;
    border-radius: 6px 6px 0 0;
}

.history-note-editor .note-editable {
    background: #fff;
    border: none;
    padding: 10px;
    min-height: 100px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline {
        padding-left: 15px;
    }
    
    .timeline-marker {
        left: -19px;
        width: 12px;
        height: 12px;
    }
    
    .timeline-content {
        padding: 10px;
    }
    
    .history-note-editor {
        padding: 5px;
    }
    
    .history-note-editor .note-editable {
        padding: 5px;
        min-height: 80px;
    }
}