/* Admin Area Global Responsive Styles */

/* Base responsive utilities */
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

.admin-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.admin-header h1 {
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.admin-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.search-box {
    min-width: 300px;
    flex: 1;
    max-width: 400px;
}

/* Responsive button groups */
.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-responsive {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

/* Table responsiveness */
.table-responsive-admin {
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.table-responsive-admin .table {
    margin-bottom: 0;
}

.table-responsive-admin .table th {
    background-color: #343a40;
    color: white;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 1rem 0.75rem;
}

.table-responsive-admin .table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

/* Card layouts */
.admin-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.admin-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

/* Modal responsiveness */
.modal-responsive .modal-dialog {
    max-width: 90vw;
    margin: 1rem auto;
}

.modal-responsive .modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-responsive .modal-header {
    background-color: #f8f9fa;
    border-radius: 0.75rem 0.75rem 0 0;
    border-bottom: 1px solid #e9ecef;
}

/* Excursion Admin Modal Responsive Fixes */
@media (max-width: 1199.98px) {
    .modal-xl {
        max-width: 95vw;
    }
}

@media (max-width: 991.98px) {
    .modal-xl {
        max-width: 98vw;
        margin: 0.5rem;
    }
    
    .modal-xl .modal-content {
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
    }
    
    .modal-xl .modal-body {
        padding: 1rem;
    }
    
    /* Stack modal columns on tablet */
    .modal-xl .row .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Responsive link and geo-info cards */
    .modal-xl .links-container .card,
    .modal-xl .geoinformation-container .card {
        margin-bottom: 1rem;
    }
    
    .modal-xl .links-container .row,
    .modal-xl .geoinformation-container .row {
        margin: 0;
    }
    
    .modal-xl .links-container .col-md-3,
    .modal-xl .links-container .col-md-5,
    .modal-xl .geoinformation-container .col-md-2,
    .modal-xl .geoinformation-container .col-md-3 {
        margin-bottom: 0.5rem;
        padding: 0 0.25rem;
    }
}

@media (max-width: 767.98px) {
    .modal-xl {
        max-width: 100vw;
        margin: 0;
        height: 100vh;
    }
    
    .modal-xl .modal-dialog {
        height: 100vh;
        margin: 0;
        max-width: 100vw;
    }
    
    .modal-xl .modal-content {
        height: 100vh;
        border-radius: 0;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .modal-xl .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 0.75rem;
    }
    
    .modal-xl .modal-header,
    .modal-xl .modal-footer {
        flex-shrink: 0;
        border-radius: 0;
    }
    
    /* Stack all modal form elements */
    .modal-xl .row .col-md-6,
    .modal-xl .row .col-md-3,
    .modal-xl .row .col-md-5,
    .modal-xl .row .col-md-2,
    .modal-xl .row .col-md-1 {
        width: 100%;
        margin-bottom: 0.75rem;
        padding: 0 0.5rem;
    }
    
    /* Mobile-specific input styling */
    .modal-xl .form-control,
    .modal-xl .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Mobile button styling */
    .modal-xl .btn-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-xl .btn-group .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Mobile link cards */
    .modal-xl .links-container .card-body,
    .modal-xl .geoinformation-container .card-body {
        padding: 0.5rem;
    }
    
    /* Add labels for mobile */
    .modal-xl .form-label.mobile-label {
        display: block;
        font-size: 0.875rem;
        font-weight: 600;
        color: #495057;
        margin-bottom: 0.25rem;
    }
    
    /* Show hidden labels on mobile */
    .modal-xl .d-block.d-md-none {
        display: block !important;
    }
    
    /* Hide desktop-only text on mobile */
    .modal-xl .d-md-none {
        display: inline !important;
    }
}

@media (max-width: 575.98px) {
    .modal-xl .modal-body {
        padding: 0.5rem;
    }
    
    .modal-xl .row .col-md-6,
    .modal-xl .row .col-md-3,
    .modal-xl .row .col-md-5,
    .modal-xl .row .col-md-2,
    .modal-xl .row .col-md-1 {
        padding: 0 0.25rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-xl .form-control,
    .modal-xl .form-select {
        font-size: 16px;
        padding: 0.5rem;
    }
    
    .modal-xl .btn {
        font-size: 0.875rem;
        padding: 0.5rem;
    }
    
    .modal-xl .modal-header h5 {
        font-size: 1.1rem;
    }
    
    /* Modal footer responsive */
    .modal-footer {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 0;
    }
    
    .modal-footer .btn-secondary {
        order: 2;
    }
    
    .modal-footer .btn-primary {
        order: 1;
    }
}

/* Badge and status indicators */
.status-badge {
    font-size: 0.75rem;
    padding: 0.25em 0.5em;
    border-radius: 0.375rem;
}

/* Loading states */
.loading-overlay {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tablet styles (768px to 991px) */
@media (max-width: 991.98px) {
    .admin-container {
        padding: 0.75rem;
    }
    
    .admin-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .search-box {
        min-width: auto;
        max-width: none;
    }
    
    .btn-group-responsive {
        justify-content: center;
    }
    
    .table-responsive-admin {
        font-size: 0.85rem;
    }
    
    .table-responsive-admin .table th,
    .table-responsive-admin .table td {
        padding: 0.5rem;
    }
}

/* Mobile styles (up to 767px) */
@media (max-width: 767.98px) {
    .admin-container {
        padding: 0.5rem;
    }
    
    .admin-header {
        margin-bottom: 1rem;
        text-align: center;
    }
    
    .admin-header h1 {
        font-size: 1.5rem;
    }
    
    .admin-header p {
        font-size: 0.9rem;
    }
    
    .admin-actions {
        gap: 0.75rem;
    }
    
    .btn-group-responsive {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-responsive {
        width: 100%;
        justify-content: center;
        font-size: 0.85rem;
        padding: 0.625rem;
    }
    
    /* Hide less important table columns on mobile */
    .table-responsive-admin .table th:nth-child(n+4),
    .table-responsive-admin .table td:nth-child(n+4) {
        display: none;
    }
    
    .table-responsive-admin .table th:last-child,
    .table-responsive-admin .table td:last-child {
        display: table-cell; /* Always show actions column */
    }
    
    .admin-card .card-body {
        padding: 0.75rem;
    }
    
    .admin-card .card-title {
        font-size: 1rem;
    }
    
    .admin-card .card-text {
        font-size: 0.85rem;
    }
}

/* Small mobile styles (up to 575px) */
@media (max-width: 575.98px) {
    .admin-container {
        padding: 0.25rem;
    }
    
    .admin-header h1 {
        font-size: 1.25rem;
    }
    
    .btn-responsive {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
    
    .table-responsive-admin {
        font-size: 0.75rem;
    }
    
    .table-responsive-admin .table th,
    .table-responsive-admin .table td {
        padding: 0.375rem 0.25rem;
    }
    
    /* Show only essential columns on very small screens */
    .table-responsive-admin .table th:nth-child(n+3),
    .table-responsive-admin .table td:nth-child(n+3) {
        display: none;
    }
    
    .table-responsive-admin .table th:last-child,
    .table-responsive-admin .table td:last-child {
        display: table-cell; /* Always show actions column */
    }
    
    .modal-responsive .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    
    .modal-responsive .modal-content {
        border-radius: 0.5rem;
    }
    
    .status-badge {
        font-size: 0.65rem;
        padding: 0.2em 0.4em;
    }
    
    .btn-group .btn {
        padding: 0.25rem 0.375rem;
        font-size: 0.7rem;
    }
}

/* Print styles */
@media print {
    .admin-actions,
    .btn,
    .modal {
        display: none !important;
    }
    
    .admin-container {
        max-width: none;
        padding: 0;
    }
    
    .table-responsive-admin {
        box-shadow: none;
    }
    
    .admin-card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .admin-header {
        border-bottom-color: #495057;
    }
    
    .admin-card {
        background-color: #343a40;
        color: white;
    }
    
    .table-responsive-admin .table {
        color: white;
    }
}

/* Focus and accessibility improvements */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Smooth transitions for better UX */
.admin-card,
.btn,
.modal-content {
    transition: all 0.2s ease-in-out;
}

/* Utility classes for responsive behavior */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 767.98px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* Responsive text truncation */
.text-truncate-responsive {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

@media (max-width: 767.98px) {
    .text-truncate-responsive {
        max-width: 100px;
    }
}

@media (max-width: 575.98px) {
    .text-truncate-responsive {
        max-width: 80px;
    }
}

/* ==========================================
   CRM STYLES
   ========================================== */

/* KPI Cards */
.crm-kpi-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.crm-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.crm-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.crm-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
}

.crm-kpi-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* Stat Cards */
.crm-stat-card {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.crm-stat-card i {
    font-size: 1.5rem;
}

.crm-stat-paid i { color: #198754; }
.crm-stat-open i { color: #ffc107; }
.crm-stat-won i { color: #0d6efd; }

.crm-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.crm-stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
}

/* CRM Card */
.crm-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.crm-card .card-header {
    background: white;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.25rem;
}

.crm-card .card-header h5 {
    font-size: 1rem;
    font-weight: 600;
}

/* Pipeline */
.crm-pipeline {
    padding: 1rem 1.25rem;
}

.crm-pipeline-stage {
    margin-bottom: 0.75rem;
}

.crm-pipeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.crm-pipeline-status {
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crm-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.crm-pipeline-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
}

.crm-pipeline-bar {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.crm-pipeline-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    min-width: 4px;
}

.crm-pipeline-value {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: right;
    margin-top: 0.15rem;
}

/* Activity Timeline */
.crm-activity-timeline {
    padding: 1rem;
}

.crm-activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.crm-activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.crm-activity-email { background: #e8f4fd; color: #0d6efd; }
.crm-activity-call { background: #e8f8e8; color: #198754; }
.crm-activity-meeting { background: #fff3e0; color: #fd7e14; }
.crm-activity-message { background: #f3e8fd; color: #6f42c1; }
.crm-activity-status { background: #fde8e8; color: #dc3545; }
.crm-activity-note { background: #fff8e1; color: #ffc107; }
.crm-activity-invoice { background: #e0f2f1; color: #009688; }
.crm-activity-payment { background: #e8f5e9; color: #4caf50; }
.crm-activity-default { background: #f5f5f5; color: #6c757d; }

.crm-activity-title {
    font-size: 0.85rem;
    font-weight: 500;
}

.crm-activity-meta {
    font-size: 0.75rem;
    color: #6c757d;
}

.crm-activity-content {
    min-width: 0;
}

/* Revenue Chart (CSS-only bars) */
.crm-revenue-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 4px;
    height: 180px;
    padding: 0;
}

.crm-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.crm-chart-bar-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.crm-chart-bar {
    width: 70%;
    max-width: 40px;
    background: linear-gradient(180deg, #0d6efd, #6ea8fe);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.5s ease;
    cursor: pointer;
}

.crm-chart-bar:hover {
    background: linear-gradient(180deg, #0a58ca, #0d6efd);
}

.crm-chart-label {
    font-size: 0.6rem;
    color: #6c757d;
    text-align: center;
    margin-top: 4px;
    white-space: nowrap;
}

/* Reminder Cards */
.crm-reminder-card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.crm-reminder-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.crm-reminder-item.crm-overdue {
    background-color: #fff5f5;
}

/* Contact Cards */
.crm-contact-card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.crm-contact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.crm-contact-details div {
    padding: 0.15rem 0;
}

/* Deal Cards */
.crm-deal-card {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.crm-deal-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ---- Grouped Deal List ---- */
.crm-status-group {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.crm-status-group-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #e9ecef;
}

/* Status group header variants — light tinted backgrounds, dark readable text */
.crm-group-lead       { background: #f5f5f5; }
.crm-group-contacted  { background: #e8f4fd; }
.crm-group-negotiation{ background: #eef2ff; }
.crm-group-offer      { background: #fffbeb; }
.crm-group-won        { background: #ecfdf5; }
.crm-group-lost       { background: #fff1f2; }
.crm-group-paused     { background: #f5f5f5; }

.crm-status-group-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1a1a2e;
    flex: 1;
}

.crm-status-dot-lg {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.crm-dot-lead        { background: #6c757d; }
.crm-dot-contacted   { background: #0dcaf0; }
.crm-dot-negotiation { background: #0d6efd; }
.crm-dot-offer       { background: #ffc107; }
.crm-dot-won         { background: #198754; }
.crm-dot-lost        { background: #dc3545; }
.crm-dot-paused      { background: #343a40; }

.crm-status-group-count {
    font-size: 0.78rem;
    font-weight: 500;
    color: #6c757d;
    background: rgba(0,0,0,0.07);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
}

.crm-status-group-total {
    font-size: 0.88rem;
    font-weight: 700;
    color: #198754;
    margin-left: auto;
}

/* Individual deal row inside group */
.crm-deal-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}

.crm-deal-row:last-child {
    border-bottom: none;
}

.crm-deal-row:hover {
    background: #f8f9fa;
}

.crm-deal-row-main {
    flex: 1;
    min-width: 0;
}

.crm-deal-row-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-deal-row-company {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.1rem;
}

.crm-deal-row-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.crm-deal-row-type {
    font-size: 0.75rem;
    color: #6c757d;
    background: #f0f0f0;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.crm-deal-row-deadline {
    font-size: 0.78rem;
}

.crm-deal-row-value {
    font-size: 1rem;
    font-weight: 700;
    min-width: 4rem;
    text-align: right;
}

.crm-deal-paid-badge {
    font-size: 0.72rem;
    background: #d1fae5;
    color: #065f46;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    white-space: nowrap;
}

.crm-deal-row-action {
    flex-shrink: 0;
    opacity: 0.4;
}

.crm-deal-row:hover .crm-deal-row-action {
    opacity: 1;
}

@media (max-width: 575.98px) {
    .crm-deal-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .crm-deal-row-meta {
        width: 100%;
        justify-content: flex-start;
    }

    .crm-deal-row-action {
        display: none;
    }
}

/* Star Rating */
.crm-star-rating {
    display: flex;
    gap: 0.25rem;
    padding-top: 0.5rem;
}

/* Cursor */
.cursor-pointer {
    cursor: pointer;
}

/* CRM Dashboard specific */
.crm-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.crm-dashboard .admin-header {
    margin-bottom: 2rem;
    text-align: left;
}

.crm-dashboard .row {
    justify-content: center;
}

/* KPI Cards – more breathing room */
.crm-kpi-card {
    padding: 1.5rem;
}

.crm-kpi-value {
    font-size: 1.75rem;
}

/* Stat cards – wider feel */
.crm-stat-card {
    padding: 1.25rem 1.5rem;
    justify-content: center;
}

/* Pipeline / Charts cards – consistent inner padding */
.crm-card .card-body {
    padding: 1.25rem;
}

.crm-pipeline {
    padding: 1.25rem 1.5rem;
}

/* Revenue chart – taller for better readability */
.crm-revenue-chart {
    height: 220px;
}

/* Recent Deals table – comfortable cell padding */
.crm-dashboard .table th,
.crm-dashboard .table td {
    padding: 0.85rem 1rem;
}

/* Tablet */
@media (max-width: 991.98px) {
    .crm-dashboard {
        padding: 1rem 1.25rem;
    }
}

/* Mobile optimizations */
@media (max-width: 767.98px) {
    .crm-dashboard {
        padding: 0.75rem;
    }

    .crm-kpi-card {
        padding: 1rem;
    }

    .crm-kpi-value {
        font-size: 1.2rem;
    }

    .crm-kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .crm-revenue-chart {
        height: 150px;
    }

    .crm-chart-label {
        font-size: 0.5rem;
    }

    .crm-kanban {
        flex-direction: column;
    }

    .crm-kanban-column {
        min-width: 100%;
    }

    .crm-stat-card {
        padding: 0.75rem;
    }

    .crm-stat-value {
        font-size: 1rem;
    }
}

@media (max-width: 575.98px) {
    .crm-dashboard {
        padding: 0.5rem;
    }

    .crm-kpi-card {
        padding: 0.75rem;
    }

    .crm-kpi-value {
        font-size: 1rem;
    }

    .crm-kpi-label {
        font-size: 0.65rem;
    }

    .crm-pipeline {
        padding: 0.75rem;
    }
}

