/**
 * Unified Tailwind CSS Custom Styles
 * This file contains custom utilities and overrides that extend Tailwind
 * Note: Uses regular CSS (not @apply) for CDN compatibility
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Custom CSS Variables for consistency */
:root {
  --color-primary: #FFD100;
  --color-primary-hover: #E6BB00;
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* Base Styles */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Utility Classes - Buttons */
.btn-primary {
  background-color: #FFD100;
  color: #111827;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: #E6BB00;
  color: #111827;
}

.btn-outline {
  background-color: #e5e7eb;
  color: #1f2937;
  border: 2px solid #6b7280;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  cursor: pointer;
}

.btn-outline:hover {
  background-color: #d1d5db;
  border-color: #4b5563;
  color: #111827;
}

.btn-secondary {
  background-color: #E5E7EB;
  color: #111827;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  border: none;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: #D1D5DB;
}

.btn-danger {
  background-color: #EF4444;
  color: white;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  border: none;
  cursor: pointer;
}

.btn-danger:hover {
  background-color: #DC2626;
}

.btn-success {
  background-color: #10B981;
  color: white;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  border: none;
  cursor: pointer;
}

.btn-success:hover {
  background-color: #059669;
}

/* Card Components */
.card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  border: 1px solid #E5E7EB;
  padding: 1.5rem;
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #E5E7EB;
}

/* Form Components */
.input-field {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid #D1D5DB;
  border-radius: 0.375rem;
  outline: none;
  transition: all 0.2s;
}

.input-field:focus {
  border-color: #FFD100;
  box-shadow: 0 0 0 2px rgba(255, 209, 0, 0.2);
}

.label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

/* Badge Components */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background-color: #D1FAE5;
  color: #059669;
}

.badge-danger {
  background-color: #FEE2E2;
  color: #DC2626;
}

.badge-warning {
  background-color: #FEF3C7;
  color: #D97706;
}

.badge-info {
  background-color: #DBEAFE;
  color: #2563EB;
}

.badge-pending {
  background-color: #F3F4F6;
  color: #374151;
}

/* Sidebar Styles */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: white;
  border-right: 1px solid #E5E7EB;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid #E5E7EB;
  flex-shrink: 0;
}

.sidebar-header img,
.sidebar-header .auth-logo {
  max-width: 150px;
  max-height: 50px;
  object-fit: contain;
}

.sidebar-nav {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: #6B7280;
  text-decoration: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: all 0.2s;
  gap: 0.75rem;
}

.nav-item:hover {
  background-color: #F3F4F6;
  color: #111827;
}

.nav-item.active {
  background-color: #FEF3C7;
  color: #92400E;
  font-weight: 600;
  position: relative;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background-color: #FFD100;
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-icon {
  color: #92400E;
}

.sidebar-section-title {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9CA3AF;
  padding: 0.5rem 1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.25rem;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .sidebar-header {
  padding: 0 0.5rem;
  justify-content: center;
}

.sidebar.collapsed .sidebar-header img,
.sidebar.collapsed .auth-logo {
  display: none;
}

.sidebar.collapsed .sidebar-header::after {
  content: '☰';
  font-size: 1.5rem;
  color: #111827;
}

.sidebar.collapsed .nav-item span {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem;
  position: relative;
}

.sidebar.collapsed .nav-item:hover::after {
  content: attr(data-title);
  position: absolute;
  left: 100%;
  margin-left: 0.5rem;
  background-color: #111827;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

.sidebar.collapsed .sidebar-section-title {
  display: none;
}

/* Topbar Styles */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  background-color: white;
  border-bottom: 1px solid #E5E7EB;
  z-index: 50;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.admin-sidebar-collapsed .topbar,
body.user-sidebar-collapsed .topbar {
  left: 64px;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.admin-sidebar-collapsed .main-content,
body.user-sidebar-collapsed .main-content {
  margin-left: 64px;
}

/* Table Styles */
.table-responsive {
  overflow-x: auto;
}

.table-mobile-card {
  width: 100%;
}

.table-mobile-card thead {
  background-color: #F9FAFB;
}

.table-mobile-card th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-mobile-card td {
  padding: 1rem;
  white-space: nowrap;
  font-size: 0.875rem;
  color: #111827;
}

/* Mobile: Convert table to cards */
@media (max-width: 767px) {
  .table-mobile-card thead {
    display: none;
  }
  
  .table-mobile-card tr {
    display: block;
    margin-bottom: 1rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid #E5E7EB;
    padding: 1rem;
  }
  
  .table-mobile-card td {
    display: block;
    padding: 0.5rem 0;
    text-align: left;
  }
  
  .table-mobile-card td:before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 0.25rem;
  }
}

/* Alert/Flash Message Styles */
.alert {
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.alert-success {
  background-color: #D1FAE5;
  color: #059669;
  border: 1px solid #10B981;
}

.alert-error {
  background-color: #FEE2E2;
  color: #DC2626;
  border: 1px solid #EF4444;
}

.alert-warning {
  background-color: #FEF3C7;
  color: #D97706;
  border: 1px solid #F59E0B;
}

.alert-info {
  background-color: #DBEAFE;
  color: #2563EB;
  border: 1px solid #3B82F6;
}

/* Stat Card Styles */
.stat-card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  border: 1px solid #E5E7EB;
  padding: 1.5rem;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: #111827;
}

.stat-label {
  font-size: 0.875rem;
  color: #6B7280;
  margin-top: 0.25rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

.form-error {
  color: #EF4444;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
  border-radius: 9999px;
  height: 1rem;
  width: 1rem;
  border: 2px solid #D1D5DB;
  border-top-color: #FFD100;
}

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

/* Page Header */
.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.5rem;
}

.page-description {
  color: #6B7280;
}

/* Mobile Responsive Utilities */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .topbar {
    left: 0;
  }
}

/* Print Styles */
@media print {
  .sidebar,
  .topbar,
  .no-print {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0;
    padding-top: 0;
  }
}
