/* Left sidebar: resize handle, history list, user profile, visitor info.
 * Extracted from styles.css lines 51-682.
 */

/* Left Sidebar */
.left-sidebar {
    width: 240px;
    min-width: 180px;
    max-width: 600px;
    background-color: #ffffff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    order: 1;
    position: relative;
    transition: width 0.1s ease-out;
}

.left-sidebar.resizing {
    transition: none;
    user-select: none;
}

.left-sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.left-sidebar.collapsed ~ .sidebar-resize-handle {
    display: none;
}

.left-sidebar.collapsed ~ .main-content #expandSidebarBtn {
    display: flex !important;
}

/* Sidebar Resize Handle */
.sidebar-resize-handle {
    width: 4px;
    background-color: transparent;
    cursor: col-resize;
    position: relative;
    order: 2;
    flex-shrink: 0;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.sidebar-resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    right: -3px;
    bottom: 0;
    background-color: transparent;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
    background-color: var(--blue-accent);
}

.sidebar-resize-handle:hover::before,
.sidebar-resize-handle.resizing::before {
    background-color: rgba(3, 105, 161, 0.1);
}

body.resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

body.resizing-sidebar * {
    cursor: col-resize !important;
    user-select: none !important;
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.logo {
    font-size: 22px;
    font-weight: 500;
    padding: 8px 0;
}

.collapse-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.collapse-sidebar-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.nav-item.active {
    background-color: var(--bg-button);
    color: var(--blue-accent);
    border-radius: 8px;
    font-weight: 500;
}

.nav-item:not(.active):hover {
    background-color: var(--bg-hover);
}

.nav-item svg {
    margin-right: 16px;
    width: 20px;
    height: 20px;
}

/* History Section */
.history {
    margin-top: 32px;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 0;
}

.history h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.history-collapse-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 20px;
    height: 20px;
}

.history-collapse-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.history-collapse-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.history.collapsed .history-collapse-btn svg {
    transform: rotate(-90deg);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 1000px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.history.collapsed .history-list {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.history-item {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 16px 8px 16px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-height: 40px;
}

.history-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
    padding-right: 68px; /* Make room for buttons */
}

.history-item.active {
    background-color: var(--bg-button);
    color: var(--blue-accent);
    font-weight: 500;
}

.history-item-text {
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    max-height: calc(1.4em * 2);
}

.history-item-actions {
    position: absolute;
    right: 8px;
    top: 8px;
    display: none;
    gap: 4px;
    align-items: center;
}

.history-item:hover .history-item-actions {
    display: flex;
}

.history-item-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 24px;
    height: 24px;
}

.history-item-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.history-item-btn.delete:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.history-item-btn svg {
    width: 14px;
    height: 14px;
}

/* Edit mode for history items */
.history-item.editing {
    padding: 4px 8px;
}

.history-item.editing .history-item-text {
    display: none;
}

.history-item.editing .history-item-actions {
    display: none;
}

.history-edit-form {
    display: none;
    flex: 1;
    gap: 4px;
}

.history-item.editing .history-edit-form {
    display: flex;
}

.history-edit-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--blue-accent);
    border-radius: 4px;
    font-size: 14px;
    font-family: var(--font-family);
    outline: none;
}

.history-edit-input:focus {
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.1);
}

.history-edit-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-edit-btn.save {
    color: var(--blue-accent);
}

.history-edit-btn.save:hover {
    background-color: var(--bg-button);
}

.history-edit-btn.cancel {
    color: var(--text-secondary);
}

.history-edit-btn.cancel:hover {
    background-color: var(--bg-hover);
}

.history-edit-btn svg {
    width: 16px;
    height: 16px;
}

.history-item-loading {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.history-item-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
}

.history-loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--blue-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.load-more-history {
    width: 100%;
    padding: 8px 16px;
    margin-top: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-link);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.load-more-history:hover {
    background-color: var(--bg-hover);
    border-color: var(--blue-accent);
}

.load-more-history:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 16px 0;
}

.privacy-mode-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 16px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    transition: background-color 0.2s;
}

.privacy-mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.privacy-mode-label svg {
    color: var(--text-secondary);
}

.sidebar-footer-text {
    margin-bottom: 16px;
}

.privacy-mode-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 12px;
    background-color: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.privacy-mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.privacy-mode-label svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
}

.sidebar-footer-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-footer-links a {
    text-decoration: none;
    color: var(--text-link);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 8px 16px;
    transition: opacity 0.2s;
}

.sidebar-footer-links a:hover {
    opacity: 0.8;
}

.sidebar-footer-links a svg {
    width: 16px;
    height: 16px;
}

/* Sidebar User Profile */
.sidebar-user-profile {
    margin-bottom: 20px;
    padding-bottom: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-hover);
    border-radius: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--blue-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.user-details {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.user-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.user-email {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.signout-button:hover {
    background-color: var(--bg-hover);
    border-color: var(--blue-accent);
    color: var(--blue-accent);
}

.signout-button svg {
    flex-shrink: 0;
}

/* Visitor Info Styles */
.visitor-info {
    margin-top: 4px;
}

.visitor-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.visitor-status-badge svg {
    width: 14px;
    height: 14px;
}

.visitor-expiry {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

