@tailwind base;
@tailwind components;
@tailwind utilities;

/* General Styles */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #6c757d;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #06b6d4;
  --sidebar-width: 200px;
  --navbar-height: 56px;
}

@layer base {
  body {
    @apply font-sans antialiased text-gray-900;
    line-height: 1.6;
    letter-spacing: -0.01em;
  }
  
  h1, h2, h3, h4, h5, h6 {
    @apply font-display;
  }
}

/* Role-Based Themes */
body.theme-admin {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
}

body.theme-fin_sec {
  --primary-color: #059669;
  --primary-hover: #047857;
}

body.theme-treasurer {
  --primary-color: #ea580c;
  --primary-hover: #c43403;
}

body.theme-auditor {
  --primary-color: #0891b2;
  --primary-hover: #065666;
}

/* Bridge Tailwind with existing role-based variables */
@layer base {
  .text-primary {
    color: var(--primary-color) !important;
  }

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

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

  /* Custom component definitions using theme variables */
  .btn-primary {
    @apply bg-[var(--primary-color)] border-[var(--primary-color)] text-white font-medium rounded-lg px-4 py-2 transition-all duration-300 hover:bg-[var(--primary-hover)] hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30;
  }
}


.form-select option {
  color: #000 !important;
  /* black text */
  background-color: #fff !important;
  /* white background */
}

.form-select option {
  background-color: #fff;
  color: #212529;
}

select.form-select {
  -webkit-appearance: menulist;
  /* ensures normal dropdown */
  -moz-appearance: menulist;
  appearance: menulist;
}


/* ... (Your existing button styles: .btn-primary, .btn-secondary, etc.) ... */

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  line-height: 1.6;
}

.navbar {
  height: var(--navbar-height);
  margin-left: 0;
  z-index: 1030;
  transition: margin-left 0.3s ease;
}

/* ... (Your existing body, link, card, login, etc. styles) ... */

.container {
  max-width: 100%;
  padding: 0 15px;
  margin: 0;
  flex: 1;
}

/* Sidebar Styling - Modified and Integrated */
/* Sidebar Styles */
.sidebar {
  width: 200px;
  height: 100vh;
  background-color: #2c3e50;
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  transition: all 0.3s ease-in-out;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.sidebar a {
  padding: 10px 20px;
  display: block;
  color: #ecf0f1;
  text-decoration: none;
  font-size: 16px;
  transition: background 0.3s;
}

.sidebar a i {
  margin-right: 10px;
}

.sidebar a:hover {
  background-color: #34495e;
}

.sidebar-dropdown {
  padding-left: 10px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
}

.sidebar-item:hover .sidebar-dropdown {
  max-height: 150px;
}

.sidebar .active {
  background-color: #3a7dc3;
  color: white;
}

.sidebar-dropdown li {
  list-style: none;
}

.sidebar-item .sidebar-dropdown {
  display: none;
}

.sidebar-item a.active+.sidebar-dropdown {
  display: block;
}

.desktop-sidebar {
  display: block;
}

.mobile-sidebar {
  display: none;
}

/* Content Styling - Standardized */
.content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--navbar-height) + 20px) 20px 20px;
  min-height: calc(100vh - var(--navbar-height));
  transition: margin-left 0.3s ease;
}

/* Primary Button - Consolidated */
.btn-primary {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: #fff !important;
  transition: all 0.3s ease;
  font-weight: 500;
  border-radius: 6px;
  padding: 8px 16px;
}

.btn-primary:hover {
  background-color: var(--primary-hover, #1d4ed8) !important;
  border-color: var(--primary-hover, #1d4ed8) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* Secondary Button */
.btn-secondary {
  background-color: #6c757d;
  /* Modern Gray */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

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

/* Success Button */
.btn-success {
  background-color: #3a8e60;
  /* Vibrant Green */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

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

.bg-success {
  background-color: #3a8e60;
  /* Vibrant Green */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

/* Danger Button */
.btn-danger {
  background-color: #ea5455;
  /* Soft Red */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

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

/* Warning Button */
.btn-warning {
  background-color: #c2752d;
  /* Orange Shade */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

.btn-warning:hover {
  background-color: #ff851b;
}

.bg-warning {
  background-color: #c2752d;
  /* Orange Shade */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

/* Info Button */
.btn-info {
  background-color: #330f68;
  /* Cyan Blue */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

.btn-info:hover {
  background-color: #00b3cc;
}

.bg-info {
  background-color: #330f68;
  /* Cyan Blue */
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

/* Light Button */
.btn-light {
  background-color: #f8f9fa;
  border: 1px solid #d6d8db;
  color: #333;
}

.btn-light:hover {
  background-color: #e2e6ea;
}

/* Dark Button */
.btn-dark {
  background-color: #343a40;
  border: none;
  color: #fff;
  transition: background 0.3s ease;
}

.btn-dark:hover {
  background-color: #23272b;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  line-height: 1.6;
}

a:hover {
  opacity: 0.8;
}

.card:hover {
  transform: translateY(-5px);
  transition: transform 0.3s ease;
}

a:focus,
button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.card {
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Login Container */
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  /* Fallback */
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  margin: auto;
  /* Center the login container */
}

.login-box {
  background: #ffffff;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.login-box h2 {
  margin-bottom: 20px;
  font-size: 24px;
  color: #333;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #333;
  font-weight: 500;
}

.form-control {
  border-radius: 5px;
  border: 1px solid #ddd;
  padding: 10px;
  font-size: 16px;
}

.btn {
  border: none;
  padding: 10px;
  font-size: 16px;
  border-radius: 5px;
  margin-top: 10px;
  cursor: pointer;
  transition: background 0.3s ease;
}


.btn-secondary {
  background: var(--secondary-color);
  color: #fff;
}

.btn-secondary:hover {
  background: #5a6268;
}

.text-center a {
  color: #007bff;
  text-decoration: none;
}

.text-center a:hover {
  text-decoration: underline;
}

.navbar {
  margin-bottom: 0;
}

.rounded-circle {
  border: 2px solid #dee2e6;
  padding: 5px;
}



/* Footer Styling */
.footer {
  padding: 20px 0;
  background-color: #f8f9fa;
  text-align: center;
  margin-top: auto;
  /* Push footer to the bottom */
}

/* Responsive Design - Enhanced */
@media (max-width: 1200px) {
  .sidebar {
    width: 180px;
  }
  .content {
    margin-left: 180px;
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: 160px;
  }
  .content {
    margin-left: 160px;
    padding: calc(var(--navbar-height) + 15px) 15px 15px;
  }
}

@media (max-width: 768px) {
  .desktop-sidebar {
    display: none;
  }

  .mobile-sidebar {
    display: flex;
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    background: linear-gradient(to top, #2c3e50, #34495e);
  }

  .mobile-sidebar a {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #ecf0f1;
    flex: 1;
    min-width: 0;
  }

  .mobile-sidebar a i {
    display: block;
    margin-bottom: 4px;
    font-size: 18px;
    margin-right: 0;
  }

  .sidebar-dropdown,
  .sidebar-item:hover .sidebar-dropdown {
    display: none !important;
  }

  .content {
    margin-left: 0;
    padding: calc(var(--navbar-height) + 60px) 10px 10px;
    padding-bottom: 80px; /* Account for mobile bottom nav */
  }

  .navbar {
    margin: 0;
    padding: 0 15px;
  }

  .table-responsive {
    font-size: 14px;
  }

  .card {
    margin-bottom: 15px;
  }

  .btn {
    padding: 10px 12px;
    font-size: 14px;
  }

  .modal-dialog {
    margin: 10px;
  }

  .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

@media (max-width: 576px) {
  .content {
    padding: calc(var(--navbar-height) + 60px) 5px 5px;
  }

  .table-responsive {
    font-size: 12px;
  }

  .card-body {
    padding: 15px;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }

  .modal-dialog {
    margin: 5px;
  }
}

/* Enhanced Sidebar Dropdowns */
.sidebar-item {
  position: relative;
}

.sidebar-item > a {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #34495e;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  max-height: 300px;
  overflow-y: auto;
}

.sidebar-item:hover .sidebar-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sidebar-dropdown li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-dropdown li a {
  padding: 12px 20px;
  display: block;
  color: #ecf0f1;
  text-decoration: none;
  transition: background 0.3s ease;
  border-left: 3px solid transparent;
}

.sidebar-dropdown li a:hover {
  background: rgba(37, 99, 235, 0.1);
  border-left-color: var(--primary-color);
}

.sidebar-dropdown li a i {
  margin-right: 10px;
  width: 16px;
  text-align: center;
}

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

.sidebar-item:hover .dropdown-icon {
  transform: rotate(180deg);
}

/* Print Styles - Enhanced */
@media print {
  .sidebar,
  .navbar,
  .btn,
  .no-print,
  form,
  .modal,
  .pagination,
  .dropdown,
  .mobile-sidebar {
    display: none !important;
  }

  .content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 20px;
  }

  .table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 12px;
  }

  th, td {
    border: 1px solid #000 !important;
    padding: 8px;
  }

  .text-primary {
    color: #000 !important;
  }

  .bg-primary {
    background: #f0f0f0 !important;
    color: #000 !important;
  }
}