/* TailAdmin Custom Styles for Sales CRM */

/* =============================================================================
   CSS CUSTOM PROPERTIES (CSS Variables)
   ============================================================================= */
:root {
  /* Primary Colors - TailAdmin Theme */
  --primary: #3c50e0;
  --primary-dark: #2c3eb8;
  --primary-light: #4f67f0;

  /* Neutral Colors */
  --stroke: #e2e8f0;
  --gray-1: #f8fafc;
  --gray-2: #f1f5f9;
  --gray-3: #e2e8f0;
  --gray-4: #cbd5e1;
  --gray-5: #94a3b8;
  --gray-6: #64748b;
  --gray-7: #475569;
  --gray-8: #334155;
  --gray-9: #1e293b;

  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Primary Color Utilities */
.text-primary {
  color: var(--primary);
}

.border-primary {
  border-color: var(--primary);
}

.bg-primary {
  background-color: var(--primary);
}

.bg-primary-dark {
  background-color: var(--primary-dark);
}

.border-stroke {
  border-color: var(--stroke);
}

/* Focus States */
.focus\:border-primary:focus {
  border-color: var(--primary);
}

/* Hover States */
.hover\:bg-primary-dark:hover {
  background-color: var(--primary-dark);
}

.hover\:text-primary:hover {
  color: var(--primary);
}

/* =============================================================================
   COMPONENT STYLES
   ============================================================================= */

/* User Dropdown Button Styling */
.user-dropdown button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* Form Input Components */
.form-input {
  background: transparent;
  border: 1px solid var(--stroke);
  border-radius: var(--border-radius);
  padding: 16px 24px;
  width: 100%;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-9);
  outline: none;
  transition: all 0.2s ease-in-out;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(60 80 224 / 0.1);
}

.form-input::placeholder {
  color: var(--gray-5);
}

.form-input:disabled {
  background-color: var(--gray-1);
  color: var(--gray-5);
  cursor: not-allowed;
}

.form-input[readonly] {
  background-color: var(--gray-1);
  color: var(--gray-6);
  cursor: default;
}

.form-input:disabled[readonly] {
  background-color: var(--gray-1);
  color: var(--gray-5);
  cursor: not-allowed;
}

/* Form Label */
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-7);
  margin-bottom: 8px;
}

/* Button Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  outline: none;
}

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

/* =============================================================================
   DASHBOARD SPECIFIC STYLES
   ============================================================================= */

/* Dashboard Layout */
.dashboard-container {
  min-height: 100vh;
  background-color: var(--gray-1);
  display: flex;
}

/* Main content area */
.main-content {
  flex: 1;
  min-width: 0;
  background-color: var(--gray-1);
}

/* Sidebar Styles */
.sidebar {
  background: white;
  border-right: 1px solid var(--stroke);
  height: 100vh;
  overflow-y: auto;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 0.5);
  z-index: 40;
  transition: opacity 0.3s ease;
}

.sidebar-mobile {
  position: relative;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 20rem;
  background: white;
}

.sidebar-mobile:not(.hidden) {
  display: flex;
}

/* Sidebar Navigation */
.nav-link {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  margin: 2px 0;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid transparent;
  border-radius: 0 6px 6px 0;
  color: var(--gray-6);
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--gray-9);
  background-color: var(--gray-1);
}

.nav-link.active {
  background-color: rgb(60 80 224 / 0.1);
  border-left-color: var(--primary);
  color: var(--primary);
}

.nav-link.active .nav-icon {
  color: var(--primary);
}

.nav-icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
  flex-shrink: 0;
  color: var(--gray-4);
  transition: color 0.2s ease;
}

.nav-link:hover .nav-icon {
  color: var(--gray-5);
}

/* Header Styles */
.dashboard-header {
  background: white;
  border-bottom: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm);
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  box-shadow: var(--shadow-sm);
}

/* User Menu */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

/* User dropdown styling */
.user-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  width: 12rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  border: 1px solid #e5e7eb;
  z-index: 50;
  transition: all 0.15s ease-out;
}

.user-dropdown.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
}

.user-dropdown:not(.hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Dropdown arrow rotation */
[data-dropdown-arrow] {
  transition: transform 0.2s ease;
}

[data-user-menu].open [data-dropdown-arrow] {
  transform: rotate(180deg);
}

/* User menu button hover state */
[data-user-menu-toggle]:hover {
  background-color: var(--gray-1);
}

/* Smooth transitions for dropdown items */
.user-dropdown a {
  transition: all 0.15s ease;
}

.user-dropdown a:hover {
  background-color: var(--gray-1);
  padding-left: 1.25rem;
}

/* Focus states for accessibility */
[data-user-menu-toggle]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.user-dropdown:focus {
  outline: none;
}

/* Stats Cards */
.stats-card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--stroke);
}

.stats-icon {
  width: 24px;
  height: 24px;
  color: var(--gray-4);
}

.stats-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-9);
  line-height: 1;
}

.stats-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-5);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.stats-change {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stats-change.positive {
  color: var(--success);
}

.stats-change.negative {
  color: var(--error);
}

/* Content Cards */
.content-card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.content-card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--stroke);
}

.content-card-body {
  padding: 20px 24px;
}

/* Activity Timeline */
.activity-timeline {
  position: relative;
}

.activity-item {
  position: relative;
  padding-bottom: 32px;
}

.activity-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background-color: var(--gray-2);
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: white;
  border: 4px solid white;
}

.activity-icon.success {
  background-color: var(--success);
}

.activity-icon.info {
  background-color: var(--info);
}

.activity-icon.warning {
  background-color: var(--warning);
}

/* Quick Actions */
.quick-action {
  position: relative;
  display: block;
  width: 100%;
  border: 2px dashed var(--gray-3);
  border-radius: var(--border-radius);
  padding: 24px;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
}

.quick-action:hover {
  border-color: var(--gray-4);
  background-color: var(--gray-1);
}

.quick-action:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
}

.quick-action-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 8px;
  color: var(--gray-4);
}

.quick-action-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-9);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .sidebar-mobile {
    position: fixed;
    top: 0;
    left: -100%;
    z-index: 50;
    width: 20rem;
    height: 100vh;
    transition: left 0.3s ease;
    background: white;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  }

  .sidebar-mobile.show {
    left: 0;
  }
}

/* Animations for Dashboard */
.fade-in-up {
  animation: fadeInUp 0.3s ease-out;
}

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

.slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

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

/* Show/hide utilities */
.show {
  display: block !important;
}

.opacity-0 {
  opacity: 0;
}

.opacity-100 {
  opacity: 1;
}

/* Transform utilities */
.translate-x-0 {
  transform: translateX(0);
}

.translate-x-full {
  transform: translateX(100%);
}

.-translate-x-full {
  transform: translateX(-100%);
}

/* Transition utilities */
.transition-opacity {
  transition: opacity 0.3s ease;
}

.transition-transform {
  transition: transform 0.3s ease;
}

/* Z-index utilities */
.z-40 {
  z-index: 40;
}

.z-50 {
  z-index: 50;
}

/* Login Form Container */
.login-container {
  background: white;
  min-height: 100vh;
}

.login-form {
  max-width: 400px;
  width: 100%;
}

.login-background {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  position: relative;
  overflow: hidden;
}

.login-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,%3Csvg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" fill-rule="evenodd"%3E%3Cg fill="%23ffffff" fill-opacity="0.1"%3E%3Ccircle cx="7" cy="7" r="1"/%3E%3Ccircle cx="27" cy="7" r="1"/%3E%3Ccircle cx="47" cy="7" r="1"/%3E%3Ccircle cx="7" cy="27" r="1"/%3E%3Ccircle cx="27" cy="27" r="1"/%3E%3Ccircle cx="47" cy="27" r="1"/%3E%3Ccircle cx="7" cy="47" r="1"/%3E%3Ccircle cx="27" cy="47" r="1"/%3E%3Ccircle cx="47" cy="47" r="1"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
  pointer-events: none;
}

/* Login Background Image */
.login-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Error Messages */
.error-message {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--border-radius);
  padding: 16px;
  color: #dc2626;
  font-size: 14px;
}

/* Checkbox Styling */
.form-checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid var(--stroke);
  border-radius: 4px;
  background: white;
}

.form-checkbox:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
  .login-form {
    padding: 20px;
  }

  .btn-lg {
    padding: 14px 24px;
    font-size: 14px;
  }
}

/* =============================================================================
   ANIMATION UTILITIES
   ============================================================================= */

.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

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

.slide-in {
  animation: slideIn 0.3s ease-in-out;
}

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

/* =============================================================================
   GRADIENT UTILITIES FOR TAILWIND
   ============================================================================= */

.from-primary\/20 {
  --tw-gradient-from: rgb(60 80 224 / 0.2);
  --tw-gradient-to: rgb(60 80 224 / 0);
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

.to-primary\/40 {
  --tw-gradient-to: rgb(60 80 224 / 0.4);
}

/* =============================================================================
   PROFILE MODAL STYLES
   ============================================================================= */

/* Profile Modal Styles */
.profile-modal {
  z-index: 1000;
}

.profile-tab {
  min-height: 400px;
}

.user-avatar.w-16 {
  width: 64px;
  height: 64px;
  font-size: 1.5rem;
}

/* Form input disabled state */
.form-input:disabled {
  background-color: var(--gray-1);
  color: var(--gray-5);
  cursor: not-allowed;
  border-color: var(--gray-3);
}

.form-input:enabled {
  background-color: white;
  color: var(--gray-9);
  border-color: var(--stroke);
}

.form-input:enabled:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(60 80 224 / 0.1);
}

/* Modal animations */
.profile-modal.show {
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Button variants */
.btn.bg-gray-300 {
  background-color: #d1d5db;
  color: #374151;
  border-color: #d1d5db;
}

.btn.bg-gray-300:hover {
  background-color: #9ca3af;
}

/* Profile info display */
.profile-info-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-2);
}

.profile-info-item:last-child {
  border-bottom: none;
}

/* =============================================================================
   PROFILE PAGE STYLES
   ============================================================================= */

/* Profile navigation tabs */
.profile-nav-tab {
  border-bottom: 2px solid transparent;
  color: var(--gray-5);
  transition: all 0.2s ease;
}

.profile-nav-tab:hover {
  color: var(--gray-7);
  border-bottom-color: var(--gray-3);
}

.profile-nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Profile tab content */
.profile-tab-content {
  animation: fadeIn 0.3s ease-in-out;
}

.profile-tab-content.hidden {
  display: none;
}

/* Profile page specific styling */
.profile-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

/* Message notifications */
.notification {
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =============================================================================
   TABLE CELL TRUNCATION STYLES
   ============================================================================= */

/* Company name truncation for tables */
.company-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  transition: all 0.2s ease;
  display: block;
  word-break: break-all;
  word-wrap: break-word;
}

.company-cell:hover {
  position: relative;
  z-index: 10;
}

/* Responsive company cell widths */
@media (max-width: 1280px) {
  .company-cell {
    max-width: 160px;
  }
}

@media (max-width: 1024px) {
  .company-cell {
    max-width: 140px;
  }
}

@media (max-width: 768px) {
  .company-cell {
    max-width: 120px;
  }
}

@media (max-width: 640px) {
  .company-cell {
    max-width: 100px;
  }
}

/* Enhanced tooltip styling */
.company-cell[title]:hover:after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-bottom: 8px;
  animation: tooltipFadeIn 0.2s ease-out;
}

.company-cell[title]:hover:before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gray-9);
  z-index: 1000;
  pointer-events: none;
  margin-bottom: 3px;
  animation: tooltipFadeIn 0.2s ease-out;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
