/**
 * Frontend Admin Dashboard CSS
 * 
 * @package Client_Portal
 */

/* Custom animations and transitions */
.modal-overlay {
    backdrop-filter: blur(4px);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tab navigation enhancements */
.tab-button {
    transition: all 0.2s ease-in-out;
    position: relative;
}

.tab-button:hover {
    transform: translateY(-1px);
}

.tab-button.active {
    background-color: #f0f9ff;
    color: #1e40af;
    border-color: #3b82f6;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #3b82f6;
}

/* Card hover effects */
.stat-card {
    transition: all 0.2s ease-in-out;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Form enhancements */
.form-input, input[type="text"], input[type="email"], input[type="url"], textarea, select {
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease-in-out;
    background-color: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.form-input:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, textarea:focus, select:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    background-color: #fafbff;
}

.form-input::placeholder, input::placeholder, textarea::placeholder {
    color: #9ca3af;
    font-style: italic;
}

.form-input:hover:not(:focus), input:hover:not(:focus), textarea:hover:not(:focus), select:hover:not(:focus) {
    border-color: #9ca3af;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

/* Form labels */
.form-label, label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    margin-bottom: 6px;
    display: block;
}

/* Form groups */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Required field indicators */
.form-label.required::after {
    content: " *";
    color: #ef4444;
    font-weight: bold;
}

/* Form validation states */
.form-input.error, input.error, textarea.error, select.error {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.form-input.success, input.success, textarea.success, select.success {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.form-error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
}

.form-error-message::before {
    content: "⚠";
    margin-right: 4px;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button enhancements */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    transition: all 0.2s ease-in-out;
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Modal enhancements */
.modal-enter {
    animation: modalEnter 0.3s ease-out;
}

.modal-leave {
    animation: modalLeave 0.3s ease-in;
}

.modal-backdrop {
    backdrop-filter: blur(6px);
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    z-index: 1001;
    border-radius: 12px 12px 0 0;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    z-index: 1002;
}

.modal-close-btn:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.modal-close-btn svg {
    width: 16px;
    height: 16px;
    stroke: #6b7280;
    stroke-width: 2;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes modalLeave {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* Status indicators */
.status-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.status-indicator.connected::before {
    content: '';
    position: absolute;
    left: -12px;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.disconnected::before {
    content: '';
    position: absolute;
    left: -12px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Drag and drop for tabs */
.tab-item {
    transition: all 0.2s ease-in-out;
}

.tab-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tab-item.sortable-dragging {
    opacity: 0.6;
    transform: rotate(5deg);
}

.tab-item.sortable-placeholder {
    background-color: #f3f4f6;
    border: 2px dashed #d1d5db;
}

.drag-handle:hover {
    color: #6b7280;
}

/* File upload areas */
.file-upload-area {
    border: 2px dashed #d1d5db;
    transition: all 0.2s ease-in-out;
}

.file-upload-area:hover {
    border-color: #3b82f6;
    background-color: #f0f9ff;
}

.file-upload-area.dragover {
    border-color: #3b82f6;
    background-color: #f0f9ff;
    transform: scale(1.02);
}

/* Activity timeline */
.activity-timeline {
    position: relative;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e5e7eb;
}

.activity-item {
    position: relative;
    padding-left: 50px;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 8px;
    width: 12px;
    height: 12px;
    background-color: #3b82f6;
    border-radius: 50%;
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 1px #e5e7eb;
}

/* Search results */
.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Company selector enhancements */
.company-selector {
    position: relative;
}

.company-selector select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px 16px;
    padding-right: 40px;
}

/* Stats cards with gradients */
.stats-gradient-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
}

.stats-gradient-green {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
}

.stats-gradient-purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #5b21b6 100%);
}

.stats-gradient-orange {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Notification styles */
.notification {
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9) 0%, rgba(5, 150, 105, 0.9) 100%);
}

.notification-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.9) 100%);
}

.notification-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(29, 78, 216, 0.9) 100%);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-content {
        margin: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .stat-card {
        text-align: center;
    }
    
    .tab-button {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .activity-item {
        padding-left: 40px;
    }
    
    .activity-item::before {
        left: 8px;
        width: 10px;
        height: 10px;
    }
    
    .activity-timeline::before {
        left: 12px;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .dark\:bg-gray-800 {
        background-color: #1f2937;
    }
    
    .dark\:text-white {
        color: #ffffff;
    }
    
    .dark\:border-gray-700 {
        border-color: #374151;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .modal-overlay {
        display: none !important;
    }
    
    .stat-card {
        break-inside: avoid;
    }
}

/* Custom utilities */
.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bg-pattern {
    background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0);
    background-size: 20px 20px;
}

.border-gradient {
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #3b82f6, #8b5cf6) border-box;
}

/* Accessibility improvements */
.focus\:outline-blue:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .stat-card {
        border: 2px solid;
    }
    
    .btn-primary {
        background: #000000;
        color: #ffffff;
        border: 2px solid #000000;
    }
    
    .btn-secondary {
        background: #ffffff;
        color: #000000;
        border: 2px solid #000000;
    }
}
