/* IoT CRM - Custom Styles */
/* Colors: Navy #000080, Red #FF0000, White */

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Sidebar Navigation Links */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}
.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.15);
    box-shadow: 0 0 20px rgba(0,0,128,0.3);
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #FF0000;
    border-radius: 0 3px 3px 0;
}

/* Card Styles */
.crm-card {
    background: #fff;
    border-radius: 1rem;
    border: 1px solid #E2E8F0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.crm-card:hover {
    box-shadow: 0 10px 40px -10px rgba(0,0,128,0.1);
    border-color: #c7d2fe;
}

/* Stat Card */
.stat-card {
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0,0,128,0.03) 0%, transparent 70%);
    transition: all 0.5s ease;
}
.stat-card:hover::after {
    top: -30%;
    right: -30%;
}

/* Table Styles */
.crm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.crm-table thead th {
    background: #F8FAFC;
    padding: 0.75rem 1rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748B;
    text-align: left;
    border-bottom: 1px solid #E2E8F0;
    position: sticky;
    top: 0;
    z-index: 5;
}
.crm-table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: #334155;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}
.crm-table tbody tr {
    transition: background 0.15s ease;
}
.crm-table tbody tr:hover {
    background: #F8FAFC;
}

/* Button Styles */
.btn-primary {
    background: #000080;
    color: #fff;
    padding: 0.625rem 1.25rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}
.btn-primary:hover {
    background: #00006B;
    box-shadow: 0 4px 20px rgba(0,0,128,0.3);
    transform: translateY(-1px);
}
.btn-danger {
    background: #FF0000;
    color: #fff;
    padding: 0.625rem 1.25rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-danger:hover {
    background: #CC0000;
    box-shadow: 0 4px 20px rgba(255,0,0,0.3);
    transform: translateY(-1px);
}
.btn-outline {
    background: transparent;
    color: #000080;
    padding: 0.625rem 1.25rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border: 1.5px solid #000080;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}
.btn-outline:hover {
    background: #000080;
    color: #fff;
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 0.5rem;
}
.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8125rem;
}

/* Form Inputs */
.crm-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid #E2E8F0;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    color: #1E293B;
    background: #fff;
    transition: all 0.2s ease;
    outline: none;
    font-family: 'Inter', sans-serif;
}
.crm-input:focus {
    border-color: #000080;
    box-shadow: 0 0 0 3px rgba(0,0,128,0.08);
}
.crm-input::placeholder {
    color: #94A3B8;
}
.crm-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid #E2E8F0;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    color: #1E293B;
    background: #fff;
    transition: all 0.2s ease;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    font-family: 'Inter', sans-serif;
}
.crm-select:focus {
    border-color: #000080;
    box-shadow: 0 0 0 3px rgba(0,0,128,0.08);
}
.crm-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid #E2E8F0;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    color: #1E293B;
    background: #fff;
    transition: all 0.2s ease;
    outline: none;
    resize: vertical;
    min-height: 80px;
    font-family: 'Inter', sans-serif;
}
.crm-textarea:focus {
    border-color: #000080;
    box-shadow: 0 0 0 3px rgba(0,0,128,0.08);
}
.crm-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.375rem;
}

/* Modal */
.crm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}
.crm-modal {
    background: #fff;
    border-radius: 1rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.crm-modal-sm { max-width: 480px; }
.crm-modal-md { max-width: 640px; }
.crm-modal-lg { max-width: 800px; }
.crm-modal-xl { max-width: 1024px; }
.crm-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 5;
    border-radius: 1rem 1rem 0 0;
}
.crm-modal-body { padding: 1.5rem; }
.crm-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #E2E8F0;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-radius: 0 0 1rem 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes pulse-ring {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-slideUp { animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-scaleIn { animation: scaleIn 0.3s ease; }
.animate-slideDown { animation: slideDown 0.3s ease; }

/* Staggered Animation for Lists */
.stagger-item {
    opacity: 0;
    animation: slideUp 0.4s ease forwards;
}
.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.4s; }

/* Tab Styles */
.crm-tabs {
    display: flex;
    gap: 0.25rem;
    background: #F1F5F9;
    padding: 0.25rem;
    border-radius: 0.75rem;
}
.crm-tab {
    padding: 0.5rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748B;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
}
.crm-tab:hover { color: #000080; }
.crm-tab.active {
    background: #fff;
    color: #000080;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Pipeline / Kanban */
.pipeline-column {
    min-width: 280px;
    max-width: 280px;
    background: #F8FAFC;
    border-radius: 0.75rem;
    border: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
}
.pipeline-column-header {
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #334155;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pipeline-column-body {
    padding: 0.5rem;
    overflow-y: auto;
    flex: 1;
}
.pipeline-card {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 0.625rem;
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.pipeline-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,128,0.08);
    border-color: #c7d2fe;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
}

/* Search Bar */
.search-bar {
    position: relative;
}
.search-bar input {
    padding-left: 2.5rem;
}
.search-bar i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    font-size: 0.8125rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    animation: slideUp 0.3s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #94A3B8;
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}


/* ============================================
   PAGE LOADER
   ============================================ */
@keyframes loader-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.03); opacity: 0.85; }
}
.animate-loader-pulse {
    animation: loader-pulse 1.8s ease-in-out infinite;
}

@keyframes loader-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}
.animate-loader-dot {
    animation: loader-dot 1.2s ease-in-out infinite;
}

#pageLoader {
    transition: opacity 0.5s ease-out;
}

/* ============================================
   TOGGLE SWITCH (for departments)
   ============================================ */
input[type="checkbox"].sr-only:checked + div {
    background-color: #000080;
}
input[type="checkbox"].sr-only + div::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}
input[type="checkbox"].sr-only:checked + div::after {
    transform: translateX(18px);
}

/* System settings toggle (larger) */
label.relative input[type="checkbox"].sr-only:checked + div {
    background-color: #000080;
}

/* ============================================
   SIDEBAR NAV TRANSITION
   ============================================ */
.nav-link[data-nav] {
    position: relative;
}
.nav-link[data-nav]::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: #FF0000;
    border-radius: 3px 0 0 3px;
    transition: transform 0.2s ease;
}
.nav-link[data-nav].active::after {
    transform: translateY(-50%) scaleY(1);
}

/* ============================================
   PHOTO UPLOAD HOVER
   ============================================ */
.photo-upload-overlay {
    opacity: 0;
    transition: opacity 0.2s ease;
}
.group:hover .photo-upload-overlay {
    opacity: 1;
}

/* ============================================
   FEATURE TAG ANIMATION
   ============================================ */
.crm-card .flex-wrap .inline-flex {
    transition: all 0.2s ease;
}
.crm-card .flex-wrap .inline-flex:hover {
    transform: scale(1.05);
}

/* Deal Stage Colors */
.stage-qualification { border-left: 3px solid #3B82F6; }
.stage-proposal { border-left: 3px solid #F59E0B; }
.stage-negotiation { border-left: 3px solid #F97316; }
.stage-contract { border-left: 3px solid #8B5CF6; }
.stage-won { border-left: 3px solid #10B981; }
.stage-lost { border-left: 3px solid #EF4444; }

/* Responsive */
@media (max-width: 1024px) {
    .pipeline-column {
        min-width: 260px;
    }
}