/**
 * Tenant Portal Custom Styles
 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --body-bg: #f5f5f5;
    --card-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    --border-radius: 0.375rem;
}

/* Dark theme variables */
[data-bs-theme="dark"] {
    --body-bg: #1a1a1a;
    --card-shadow: 0 0.125rem 0.25rem rgba(255,255,255,.075);
}

/* ============================================
   Dark Mode - Background Overrides
   ============================================ */

/* Override bg-light for general containers */
[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-secondary-bg) !important;
}

/* Override bg-white for content areas */
[data-bs-theme="dark"] .bg-white {
    background-color: var(--bs-body-bg) !important;
}

/* Cards with bg-light need slightly different treatment */
[data-bs-theme="dark"] .card.bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

/* Badges with bg-light text-dark pattern */
[data-bs-theme="dark"] .badge.bg-light {
    background-color: var(--bs-secondary-bg) !important;
}
[data-bs-theme="dark"] .badge.bg-light.text-dark {
    color: var(--bs-body-color) !important;
}

/* Footer specific styling */
[data-bs-theme="dark"] footer.bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    border-top: 1px solid var(--bs-border-color);
}

[data-bs-theme="dark"] footer .text-muted,
[data-bs-theme="dark"] footer .text-muted a {
    color: var(--bs-secondary-color) !important;
}

[data-bs-theme="dark"] footer a:hover {
    color: var(--bs-body-color) !important;
}

/* Base styles */
body {
    background-color: var(--body-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

/* Login page styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0a58ca 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.login-header {
    background-color: var(--primary-color);
    color: white;
    padding: 2rem;
    text-align: center;
}

.login-header h3 {
    margin: 0;
    font-weight: 300;
}

.login-header i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Card enhancements */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: fadeInUp 0.4s ease-out;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,.1);
}

/* Fade in animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for dashboard widgets */
.dashboard-widget { animation: fadeInUp 0.4s ease-out backwards; }
.row > div:nth-child(1) .dashboard-widget { animation-delay: 0.1s; }
.row > div:nth-child(2) .dashboard-widget { animation-delay: 0.2s; }
.row > div:nth-child(3) .dashboard-widget { animation-delay: 0.3s; }
.row > div:nth-child(4) .dashboard-widget { animation-delay: 0.4s; }

/* Stagger animation for other cards */
.row > div:nth-child(1) .card { animation-delay: 0.1s; }
.row > div:nth-child(2) .card { animation-delay: 0.2s; }
.row > div:nth-child(3) .card { animation-delay: 0.3s; }
.row > div:nth-child(4) .card { animation-delay: 0.4s; }

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,.125);
    font-weight: 600;
}

/* Dashboard widgets */
.dashboard-widget {
    text-align: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.dashboard-widget::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(13, 110, 253, 0.05) 0%, transparent 70%);
    transform: rotate(45deg);
    transition: all 0.3s ease;
}

.dashboard-widget:hover::before {
    transform: rotate(45deg) scale(1.1);
}

.dashboard-widget .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.dashboard-widget:hover .icon {
    transform: scale(1.1);
    opacity: 1;
}

.dashboard-widget h4 {
    font-size: 2rem;
    margin: 0;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.dashboard-widget p {
    margin: 0;
    color: var(--secondary-color);
    position: relative;
    z-index: 1;
}

/* Animate numbers on load */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-widget h4 {
    animation: countUp 0.5s ease-out;
}

/* Status badges */
.badge-status-paid {
    background-color: var(--success-color);
}

.badge-status-pending {
    background-color: var(--warning-color);
    color: var(--dark-color);
}

.badge-status-overdue {
    background-color: var(--danger-color);
}

.badge-priority-low {
    background-color: var(--info-color);
}

.badge-priority-medium {
    background-color: var(--warning-color);
    color: var(--dark-color);
}

.badge-priority-high {
    background-color: var(--danger-color);
}

.badge-priority-urgent {
    background-color: var(--dark-color);
}

/* File icons */
.file-icon {
    font-size: 2.5rem;
    color: var(--secondary-color);
}

.file-icon.bi-file-earmark-pdf {
    color: #dc3545;
}

.file-icon.bi-file-earmark-word {
    color: #0d6efd;
}

.file-icon.bi-file-earmark-excel {
    color: #198754;
}

.file-icon.bi-file-earmark-image {
    color: #ffc107;
}

/* Document grid */
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.document-item {
    text-align: center;
    padding: 1rem;
    border: 1px solid var(--light-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
}

.document-item:hover {
    background-color: var(--light-color);
    transform: translateY(-2px);
}

.document-item .file-icon {
    display: block;
    margin: 0 auto 0.5rem;
}

/* Payment countdown */
.payment-countdown {
    font-size: 1.2rem;
    font-weight: 600;
}

.payment-countdown.text-danger {
    animation: pulse 2s infinite;
}

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

/* Building info accordion */
.building-info-accordion .accordion-button {
    font-weight: 500;
}

.building-info-accordion .accordion-button:not(.collapsed) {
    background-color: var(--primary-color);
    color: white;
}

.building-info-accordion .accordion-button:not(.collapsed)::after {
    filter: brightness(0) invert(1);
}

/* Request timeline */
.request-timeline {
    position: relative;
    padding-left: 2rem;
}

.request-timeline::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--light-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.25rem;
    top: 0.25rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--light-color);
}

/* Profile avatar */
.profile-avatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid var(--light-color);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 4rem;
    opacity: 0.5;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

/* List group enhancements */
.list-group-item {
    transition: all 0.2s ease;
}

.list-group-item:hover {
    background-color: var(--light-color);
}

.list-group-item.border-start {
    position: relative;
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Badge animations */
.badge {
    transition: all 0.2s ease;
}

.badge:hover {
    transform: scale(1.05);
}

/* Alert improvements */
.alert {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--light-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Table enhancements */
.table > :not(caption) > * > * {
    padding: 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(0,0,0,.02);
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255,255,255,.02);
}

/* Form enhancements */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.form-floating > label {
    color: var(--secondary-color);
}

/* Alert enhancements */
.alert {
    border: none;
    border-radius: var(--border-radius);
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* Navigation active state */
.navbar-nav .nav-link.active {
    font-weight: 600;
}

/* Utility classes */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Print styles */
@media print {
    .navbar,
    footer,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
    
    body {
        background-color: white !important;
    }
}

/* Activity feed */
.activity-feed {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: start;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--light-color);
}

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

.activity-icon {
    width: 40px;
    height: 40px;
    background-color: var(--light-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
}

.activity-icon i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.activity-content {
    flex: 1;
}

.activity-content p {
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.activity-content small {
    font-size: 0.8rem;
}

/* Contract expiry colors */
.dashboard-widget h4 small {
    font-size: 0.6em;
    font-weight: normal;
}

/* Breadcrumb styles */
.breadcrumb {
    background-color: transparent;
    padding: 0 0 1rem 0;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--secondary-color);
}

.breadcrumb-item a {
    text-decoration: none;
    color: var(--primary-color);
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--secondary-color);
}

/* Smooth refresh animation */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.btn:active .bi-arrow-clockwise {
    animation: rotate 0.5s ease-in-out;
}

/* Honeypot fields - completely hidden from users */
.honeypot-fields {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    overflow: hidden !important;
}

.honeypot-fields input {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    border: none !important;
    background: transparent !important;
    font-size: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

/* CAPTCHA styling */
.captcha-question {
    background-color: var(--light-color);
    font-weight: 600;
    text-align: center;
    border-right: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

#captcha-container {
    animation: slideDown 0.3s ease-out;
}

/* Loading states */
.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-control:disabled,
.form-check-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Loading overlay */
.form-loading {
    position: relative;
    pointer-events: none;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(1px);
    z-index: 10;
    border-radius: var(--border-radius);
}

[data-bs-theme="dark"] .form-loading::after {
    background: rgba(0, 0, 0, 0.8);
}

/* Enhanced focus styles for accessibility */
.form-control:focus,
.form-check-input:focus,
.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
    color: white;
}

/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Form validation enhancements */
.form-control.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.form-control.is-valid:focus {
    border-color: var(--success-color);
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* Enhanced alert animations */
.alert-dynamic {
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Status announcements for screen readers */
.status-announcement {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }
    
    .document-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .dashboard-widget {
        padding: 1rem;
    }
    
    .dashboard-widget .icon {
        font-size: 2rem;
    }
    
    .dashboard-widget h4 {
        font-size: 1.5rem;
    }
    
    .activity-feed {
        max-height: 300px;
    }
    
    /* Mobile CAPTCHA adjustments */
    .captcha-question {
        min-width: 100px;
        font-size: 0.9rem;
    }
    
    #captcha {
        max-width: 80px !important;
    }
}