html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

body {
  margin-bottom: 60px;
  padding-top: 70px; /* Adds padding for fixed navbar */
}

/* Ensure navigation menu is visible */
.navbar {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.navbar-nav {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.nav-item {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Override any potential Blazor attributes */
[data-blazor-id] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Enhanced table mobile optimizations */
@media (max-width: 767.98px) {
    /* Add scroll indicators */
    .table-responsive {
        position: relative;
    }
    
    .table-responsive.has-scroll-left::before {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 20px;
        background: linear-gradient(to right, rgba(255,255,255,1), rgba(255,255,255,0));
        pointer-events: none;
        z-index: 2;
        opacity: 1;
        transition: opacity 0.3s ease;
    }
    
    .table-responsive.has-scroll-right::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        width: 20px;
        background: linear-gradient(to left, rgba(255,255,255,1), rgba(255,255,255,0));
        pointer-events: none;
        z-index: 2;
        opacity: 1;
        transition: opacity 0.3s ease;
    }
    
    /* Optimize column widths for mobile */
    .table th:first-child,
    .table td:first-child {
        min-width: 80px; /* Ticket ID column */
        max-width: 80px;
    }
    
    .table th:nth-child(2),
    .table td:nth-child(2) {
        min-width: 150px; /* Title column */
    }
    
    .table th:last-child,
    .table td:last-child {
        min-width: 100px; /* Actions column */
        max-width: 100px;
    }
    
    /* Make badges smaller on mobile */
    .table .badge {
        font-size: 0.7rem;
        padding: 0.2em 0.4em;
    }
    
    /* Stack button groups vertically on very small screens */
    .btn-group {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .btn-group .btn {
        border-radius: 0.375rem !important;
    }
}

/* Enhanced form mobile optimizations */
@media (max-width: 767.98px) {
    /* Force all form rows to stack on mobile */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        margin-bottom: 1rem;
    }
    
    /* Larger form controls on mobile for better touch targets */
    .form-control,
    .form-select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better spacing for form groups */
    .form-group,
    .mb-3 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Stack input groups better */
    .input-group {
        flex-wrap: wrap;
    }
    
    .input-group .btn {
        flex: 0 0 auto;
        min-width: 50px;
        min-height: 48px;
    }
    
    /* Better label spacing */
    .form-label {
        margin-bottom: 0.75rem;
        font-weight: 600;
    }
    
    /* Better contact search on mobile */
    .list-group {
        max-height: 200px;
        overflow-y: auto;
    }
    
    .list-group-item {
        padding: 0.75rem;
        font-size: 0.9rem;
        min-height: 48px;
    }
    
    /* Stack contact cards better */
    #selectedContacts .badge {
        display: block;
        margin-bottom: 0.5rem;
        padding: 0.5rem;
    }
}

/* Enhanced mobile navigation */
@media (max-width: 991.98px) {
    .navbar-nav .dropdown-menu {
        position: static;
        float: none;
        width: auto;
        margin-top: 0;
        background-color: transparent;
        border: 0;
        box-shadow: none;
        padding-left: 1rem;
    }
    
    .navbar-nav .dropdown-item {
        padding: 0.75rem 1rem;
        color: #212529;
        font-size: 0.95rem;
        border-bottom: 1px solid #f8f9fa;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    .navbar-nav .dropdown-item:hover {
        background-color: #f8f9fa;
    }
    
    .navbar-nav .dropdown-header {
        padding: 0.75rem 1rem 0.25rem;
        font-size: 0.8rem;
        font-weight: 700;
        color: #6c757d;
        text-transform: uppercase;
    }
    
    /* Better touch targets */
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    /* Improve navbar toggler */
    .navbar-toggler {
        padding: 0.5rem 0.75rem;
        border: 1px solid #dee2e6;
        min-height: 48px;
    }
    
    .navbar-toggler:focus {
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    }
}

/* Mobile-specific utility classes */
@media (max-width: 767.98px) {
    /* Better button spacing utility */
    .mobile-btn-stack {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .mobile-btn-stack .btn {
        width: 100%;
        min-height: 48px;
    }
    
    /* Mobile card layout for tables */
    .mobile-card-item {
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        padding: 1rem;
        margin-bottom: 1rem;
        background: white;
    }
    
    .mobile-card-item .card-title {
        font-size: 1.1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
    }
    
    .mobile-card-item .card-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .mobile-card-item .card-meta-item {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-card-item .card-meta-label {
        font-size: 0.8rem;
        color: #6c757d;
        margin-bottom: 0.25rem;
    }
    
    .mobile-card-item .card-actions {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: 1rem;
    }
}

/* ========================================
   EXPANDABLE TICKETS FUNCTIONALITY
   ======================================== */

/* Expandable ticket row styling */
.ticket-row.expandable-enabled {
    transition: background-color 0.2s ease;
}

.ticket-row.expandable-enabled:hover {
    background-color: #f8f9fa;
}

.ticket-row.expanded {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

/* Expandable ticket details */
.ticket-details-row {
    background-color: #f8f9fa;
    border-left: 4px solid #2196f3;
}

.ticket-expanded-content {
    border-radius: 8px;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ticket-expanded-content h6 {
    color: #495057;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.ticket-expanded-content h6 i {
    margin-right: 0.5rem;
    color: #6c757d;
}

.ticket-description {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    border-left: 3px solid #17a2b8;
    font-size: 0.95rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

.requester-info {
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #28a745;
}

.recent-comments {
    max-height: 300px;
    overflow-y: auto;
}

.comment-item {
    transition: box-shadow 0.2s ease;
}

.comment-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.comment-header {
    margin-bottom: 0.5rem;
}

.comment-content {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #495057;
}

/* Mobile expandable cards */
.ticket-mobile-card.expandable-enabled {
    transition: all 0.2s ease;
}

.ticket-mobile-card.expandable-enabled:hover {
    background-color: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ticket-mobile-card.expanded {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.mobile-ticket-details {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { 
        opacity: 0;
        max-height: 0;
    }
    to { 
        opacity: 1;
        max-height: 500px;
    }
}

/* Toggle switch styling */
.form-check-input:checked {
    background-color: #2196f3;
    border-color: #2196f3;
}

.form-check-label {
    font-weight: 500;
    color: #495057;
}

/* Responsive adjustments for expandable tickets */
@media (max-width: 767.98px) {
    .ticket-expanded-content {
        padding: 1rem !important;
    }
    
    .ticket-description {
        padding: 0.75rem;
        font-size: 0.9rem;
        max-height: 150px;
    }
    
    .recent-comments {
        max-height: 200px;
    }
    
    .comment-item {
        padding: 0.5rem !important;
    }
    
    .comment-content {
        font-size: 0.85rem;
    }
}

/* ========================================
   INLINE EDITING STYLES
   ======================================== */

/* Editable field container */
.editable-field {
    position: relative;
    transition: background-color 0.2s ease;
}

.editable-field.editable {
    cursor: pointer;
}

.editable-field.editable:hover {
    background-color: #f8f9fa;
    border-radius: 4px;
}

/* Field display state */
.field-display {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.edit-indicator {
    color: #6c757d;
    font-size: 0.75em;
    transition: color 0.2s ease;
}

.editable-field:hover .edit-indicator {
    color: #007bff;
}

/* Field edit state */
.field-edit {
    min-width: 120px;
}

.field-edit .form-select {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border: 2px solid #007bff;
    border-radius: 4px;
}

.field-edit .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Field status indicators */
.field-status {
    position: absolute;
    top: 50%;
    right: -20px;
    transform: translateY(-50%);
    z-index: 10;
}

.field-status .fa-spinner {
    color: #007bff;
    animation: spin 1s linear infinite;
}

.field-status .fa-check {
    color: #28a745;
}

.field-status .fa-times {
    color: #dc3545;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status badge enhancements for inline editing */
.status-badge {
    transition: all 0.2s ease;
    min-width: 70px;
    text-align: center;
}

.editable-field.editable .status-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mobile optimizations for inline editing */
@media (max-width: 767.98px) {
    .field-edit {
        min-width: 100px;
    }
    
    .field-edit .form-select {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
    
    .field-status {
        right: -15px;
    }
    
    .edit-indicator {
        font-size: 0.7em;
    }
}

/* ========================================
   RESOLUTION INFORMATION STYLING
   ======================================== */

/* Resolution Information Section */
.resolution-info {
    animation: fadeIn 0.5s ease-in;
    border-left: 4px solid #198754 !important;
    background: linear-gradient(135deg, rgba(25, 135, 84, 0.05) 0%, rgba(25, 135, 84, 0.02) 100%);
}

.resolution-info h6 {
    color: #198754;
    font-weight: 600;
    margin-bottom: 1rem;
}

.resolution-info .badge {
    font-size: 0.8rem;
    padding: 0.4em 0.8em;
}

.resolution-info dt {
    color: #495057;
    font-weight: 600;
    font-size: 0.9rem;
}

.resolution-info dd {
    color: #212529;
    font-size: 0.9rem;
}

/* Resolution Notes Section */
.resolution-note-content {
    position: relative;
}

.resolution-note-toggle {
    border: 1px solid #198754;
    color: #198754;
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    transition: all 0.2s ease;
}

.resolution-note-toggle:hover {
    background-color: #198754;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.2);
}

/* User Avatar in Resolution Info */
.resolution-info .rounded-circle {
    background: linear-gradient(135deg, #198754 0%, #20c997 100%);
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Resolution Type Badges */
.resolution-info .badge.bg-success {
    background: linear-gradient(135deg, #198754 0%, #20c997 100%) !important;
}

.resolution-info .badge.bg-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ffeb3b 100%) !important;
    color: #000 !important;
}

.resolution-info .badge.bg-info {
    background: linear-gradient(135deg, #0dcaf0 0%, #17a2b8 100%) !important;
}

.resolution-info .badge.bg-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%) !important;
}

.resolution-info .badge.bg-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #3b82f6 100%) !important;
}

.resolution-info .badge.bg-dark {
    background: linear-gradient(135deg, #212529 0%, #495057 100%) !important;
}

.resolution-info .badge.bg-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #adb5bd 100%) !important;
}

/* Responsive Design for Resolution Info */
@media (max-width: 767.98px) {
    .resolution-info {
        padding: 1rem !important;
    }
    
    .resolution-info .row {
        margin: 0;
    }
    
    .resolution-info .col-md-6 {
        padding: 0;
        margin-bottom: 1rem;
    }
    
    .resolution-info .col-md-6:last-child {
        margin-bottom: 0;
    }
    
    .resolution-info dt {
        font-size: 0.85rem;
    }
    
    .resolution-info dd {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }
    
    .resolution-info .rounded-circle {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
    }
    
    .resolution-info .fw-semibold {
        font-size: 0.85rem;
    }
    
    .resolution-info small {
        font-size: 0.75rem;
    }
    
    .resolution-note-toggle {
        font-size: 0.8rem;
        padding: 0.2rem 0.5rem;
    }
}

/* ========================================
   FORM FIELD TEXT COLOR FIX
   ======================================== */

/* Ensure all form field text is black, not white */
.form-control,
.form-select,
.form-control:focus,
.form-select:focus,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
    color: #000000 !important;
}

/* Ensure placeholder text is visible */
.form-control::placeholder,
.form-select::placeholder,
input::placeholder,
textarea::placeholder {
    color: #6c757d !important;
    opacity: 1;
}

/* ========================================
   WIKI PHASE 3 - ADVANCED FEATURES STYLES
   ======================================== */

/* Diff Visualization Styles */
.diff-container {
    display: flex;
    gap: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

.diff-old, .diff-new {
    flex: 1;
    background: #f8f9fa;
    padding: 1rem;
    font-family: 'Courier New', Monaco, monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-x: auto;
}

.diff-old {
    border-right: 1px solid #dee2e6;
}

.diff-deleted {
    background-color: #ffebee;
    color: #c62828;
    text-decoration: line-through;
    padding: 0.1rem 0.2rem;
    margin: 0.1rem 0;
    border-radius: 0.2rem;
}

.diff-inserted {
    background-color: #e8f5e8;
    color: #2e7d32;
    font-weight: 500;
    padding: 0.1rem 0.2rem;
    margin: 0.1rem 0;
    border-radius: 0.2rem;
}

.diff-modified {
    background-color: #fff3e0;
    color: #ef6c00;
    font-weight: 500;
    padding: 0.1rem 0.2rem;
    margin: 0.1rem 0;
    border-radius: 0.2rem;
}

.diff-unchanged {
    color: #666;
    padding: 0.1rem 0.2rem;
    margin: 0.1rem 0;
}

/* Three-way diff for merge conflicts */
.three-way-diff {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

.diff-base, .diff-left, .diff-right {
    background: #f8f9fa;
    padding: 1rem;
    font-family: 'Courier New', Monaco, monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-x: auto;
}

.diff-base {
    border-right: 1px solid #dee2e6;
}

.diff-left {
    border-right: 1px solid #dee2e6;
}

/* Search result highlighting */
.search-snippet {
    font-size: 0.95rem;
    line-height: 1.5;
    border-left: 3px solid #007bff;
    background-color: #f8f9fa;
    border-radius: 0 0.375rem 0.375rem 0;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
}

.search-snippet mark {
    background-color: #fff3cd;
    padding: 0.1rem 0.3rem;
    border-radius: 0.2rem;
    font-weight: 600;
    color: #856404;
}

/* Advanced editor enhancements */
.editor-split-view {
    display: flex;
    gap: 1rem;
    height: 600px;
}

.editor-split-view .editor-pane,
.editor-split-view .preview-pane {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

/* Responsive diff container */
@media (max-width: 768px) {
    .diff-container {
        flex-direction: column;
    }
    
    .diff-old {
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    
    .three-way-diff {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .diff-base, .diff-left {
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
}