/* Custom styles for Telegram Messenger Web App */

:root {
    --primary-color: #0088cc;
    --secondary-color: #34495e;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    --dark-bg: #2c3e50;
    --light-bg: #ecf0f1;
}

body {
    background-color: #f5f5f5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Navigation */
.navbar {
    flex-shrink: 0;
    min-height: 76px;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.4rem;
}

/* Logo styling for navbar with transparent logos */
.navbar-brand img {
    /* Clean look for transparent logos */
    transition: transform 0.2s ease;
}

.navbar-brand:hover img {
    transform: scale(1.05);
}

/* Brand text styling with Futura font */
.brand-text {
    font-family: 'Futura', 'Futura-Medium', 'Futura PT', 'Century Gothic', 'Avant Garde', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    color: white;
    vertical-align: middle;
}

.navbar-brand .brand-text {
    font-size: 1.5rem; /* Match base size for consistency */
}

.brand-text strong {
    font-weight: 700;
}

/* For login page dark text */
.brand-text.text-dark {
    color: #212529;
}

/* Login page brand text - keep same size as others for consistency */
.card-header .brand-text {
    font-size: 1.5rem; /* Match base size for consistency */
    line-height: 1;
    vertical-align: middle;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
}

/* Messenger Layout - Full Height */
html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
}

/* Make main container flex to fill height */
.container-fluid.p-4 {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem !important;
    max-height: calc(100vh - 76px); /* Subtract navbar height */
}

/* Make page content fill available space */
.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Hide non-active pages */
.page-content {
    display: none !important;
}

/* Show active page with flex display */
.page-content.active {
    display: flex !important;
}

/* Make messenger row fill height */
.messenger-row {
    flex: 1;
    margin: 0;
    min-height: calc(100vh - 180px);
}

/* Make the cards fill their column height */
.chat-panel-card,
.compose-panel-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Stats panel cards don't need 100% height */
.stats-panel-card {
    display: flex;
    flex-direction: column;
}

/* Make card bodies scrollable and fill space */
.chat-panel-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.compose-panel-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.stats-panel-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sidebar column - stack cards vertically */
.col-lg-3:last-child {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.col-lg-3:last-child .card {
    flex: 1;
}

.col-lg-3:last-child .card.mb-3 {
    margin-bottom: 0 !important;
    flex: 0 0 auto;
}

.col-lg-3:last-child .card:last-child {
    flex: 1 1 auto;
    margin-bottom: 0 !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Saved Lists container */
#savedLists {
    flex: 1;
    overflow-y: auto;
}

/* Ensure the saved lists card body fills space */
.col-lg-3:last-child .card:last-child .card-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Chat Search */
#chatSearch {
    border-left: none;
}

#chatSearch:focus {
    box-shadow: none;
    border-color: #ced4da;
}

/* Compact header areas */
.chat-panel-card .border-bottom {
    padding: 0.5rem !important;
}

.chat-panel-card .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.chat-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: #f8f9fa;
}

.chat-item.selected {
    background-color: #e3f2fd;
    border-left: 3px solid var(--primary-color);
    padding-left: 12px;
}

.chat-item.selected .chat-name {
    color: var(--primary-color);
    font-weight: 600;
}

.chat-item input[type="checkbox"] {
    flex-shrink: 0;
}

.chat-item .chat-name {
    font-weight: 500;
    word-break: break-word;
    flex-grow: 1;
}

.chat-item .chat-type {
    font-size: 0.8rem;
    color: #666;
}

.chat-item .fas {
    font-size: 0.9rem;
}

.chat-item .text-truncate {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

/* Status Indicator */
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-indicator.connected {
    background-color: var(--success-color);
}

.status-indicator.disconnected {
    background-color: var(--danger-color);
}

.status-indicator.connecting {
    background-color: var(--warning-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Message Input */
#messageInput {
    font-family: 'Monaco', 'Consolas', monospace;
    resize: vertical;
    min-height: 200px;
}

/* Make compose panel content fill space */
.compose-panel-card .card-body > div:first-child {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.compose-panel-card .card-body > div:first-child .mb-3:first-child {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.compose-panel-card .card-body > div:first-child .mb-3:first-child textarea {
    flex: 1;
}

.html-mode #messageInput {
    background-color: #f8f9fa;
}

/* Progress Bars */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: #e0e0e0;
}

.progress-bar {
    transition: width 0.3s ease;
}

/* File Info */
#fileInfo {
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-top: 8px;
}

#fileInfo:empty {
    display: none;
}

/* Scheduled List */
.scheduled-item {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.scheduled-item:last-child {
    border-bottom: none;
}

.scheduled-time {
    font-size: 0.85rem;
    color: #666;
}

/* Pricing Cards */
.pricing-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.pricing-card.current {
    border-color: var(--primary-color);
    position: relative;
}

.pricing-card.current::before {
    content: "Current Plan";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.pricing-card h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.pricing-card .price {
    font-size: 2rem;
    font-weight: bold;
    margin: 20px 0;
}

.pricing-card .features {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.pricing-card .features li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.pricing-card .features li:last-child {
    border-bottom: none;
}

.pricing-card .features i {
    color: var(--success-color);
    margin-right: 8px;
}

/* Toast Notifications */
.toast {
    min-width: 300px;
}

/* Responsive */
@media (max-width: 768px) {
    .container-fluid.p-4 {
        padding: 0.5rem !important;
    }
    
    .col-lg-3, .col-lg-6 {
        margin-bottom: 1rem;
    }
    
    /* On mobile, adjust the messenger layout */
    .messenger-row {
        display: block;
    }
    
    .chat-panel-card,
    .compose-panel-card {
        height: auto;
        min-height: 400px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .card {
        background-color: #2a2a2a;
        color: #e0e0e0;
    }
    
    .card-header {
        background-color: #333;
        border-bottom-color: #444;
    }
    
    .chat-item {
        border-bottom-color: #333;
    }
    
    .chat-item:hover {
        background-color: #333;
    }
    
    .chat-item.selected {
        background-color: #1a3a52;
    }
    
    .form-control, .form-select {
        background-color: #333;
        color: #e0e0e0;
        border-color: #444;
    }
    
    .form-control:focus, .form-select:focus {
        background-color: #333;
        color: #e0e0e0;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(0, 136, 204, 0.25);
    }
    
    .modal-content {
        background-color: #2a2a2a;
        color: #e0e0e0;
    }
    
    .modal-header, .modal-footer {
        border-color: #444;
    }
    
    .list-group-item {
        background-color: #333;
        color: #e0e0e0;
        border-color: #444;
    }
}

/* Additional chat item styling */
.chat-item .chat-preview {
    margin-top: 2px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
}

/* Purple badge for supergroups */
.bg-purple {
    background-color: #6f42c1 !important;
    color: white !important;
}

/* Chat type icon circles */
.chat-type-icon {
    opacity: 0.9;
    transition: opacity 0.2s;
}

.chat-type-icon:hover {
    opacity: 1;
}

/* Softer colors for icon circles */
.chat-type-icon.bg-primary {
    background-color: #e3f2fd !important;
    color: #1976d2 !important;
}

.chat-type-icon.bg-success {
    background-color: #e8f5e9 !important;
    color: #388e3c !important;
}

.chat-type-icon.bg-info {
    background-color: #e1f5fe !important;
    color: #0288d1 !important;
}

.chat-type-icon.bg-warning {
    background-color: #fff3e0 !important;
    color: #f57c00 !important;
}

.chat-type-icon.bg-purple {
    background-color: #f3e5f5 !important;
    color: #6a1b9a !important;
}

.chat-type-icon.bg-secondary {
    background-color: #f5f5f5 !important;
    color: #616161 !important;
}

/* Ensure chat name doesn't wrap */
.chat-item .chat-name {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* Improve chat item spacing */
.chat-item {
    padding: 15px;
}

.chat-item .chat-info {
    min-width: 0; /* Allow flex item to shrink */
}

/* Visual separator after selected chats */
.chat-item.selected:last-of-type {
    border-bottom: 3px solid #2196F3;
    margin-bottom: 10px;
}

/* Smooth transitions for chat reordering */
.chat-item {
    transition: all 0.3s ease;
}

/* Saved Lists */
.saved-list-item {
    background-color: #f8f9fa;
    transition: all 0.2s ease;
    cursor: pointer;
}

.saved-list-item:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.saved-list-item strong {
    color: #333;
    font-size: 0.95rem;
}

.saved-list-item .btn {
    opacity: 0.8;
    transition: opacity 0.2s;
}

.saved-list-item:hover .btn {
    opacity: 1;
}

/* Make saved lists scrollable if many */
#savedLists {
    max-height: 400px;
    overflow-y: auto;
    min-height: 100px;
}

/* Saved list cards on the lists page */
.saved-list-card {
    transition: all 0.3s ease;
    height: 100%;
}

.saved-list-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.saved-list-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.saved-list-card .btn {
    transition: all 0.2s ease;
}

.saved-list-card .btn:hover {
    transform: translateY(-1px);
}

/* Ensure the saved lists card is visible */
.card.mt-3 {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card.mt-3 .card-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Results modal table */
#resultsModal .table {
    margin-bottom: 0;
}

#resultsModal .table th {
    background-color: #f8f9fa;
    font-weight: 600;
    white-space: nowrap;
}

#resultsModal .table td {
    vertical-align: middle;
}

/* Truncate long attachment names */
#resultsModal .table td:nth-child(5) {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#resultsModal .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Make the modal larger for the table */
#resultsModal .modal-dialog {
    max-width: 90%;
}

@media (min-width: 992px) {
    #resultsModal .modal-dialog {
        max-width: 1200px;
    }
}

/* Test chat item styling */
.test-chat-item:hover {
    background-color: #f8f9fa;
}

.test-chat-item.selected {
    background-color: #e7f3ff;
    border: 1px solid #0066cc;
}