/* ===================================================================
    CONSOLIDATED BASE STYLESHEET
    This file contains all global styles for the application.
=================================================================== */

/* ===============================
   1. Basic Reset & Fonts
================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'Bowlby One';
    src: url('../fonts/BowlbyOne-Regular.ttf') format('truetype');
    font-style: normal;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f8fafc;
    transition: opacity 0.5s ease-in-out;
}

.main-content {
    padding-top: 60px;
    overflow-y: auto;
    height: calc(100vh);
}

/* ===============================
   2. Global Animations
================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes modalFadeInUp {
    from { opacity: 0; transform: translateY(20px); background-color: rgba(0, 0, 0, 0); }
    to { opacity: 1; transform: translateY(0); background-color: rgba(0, 0, 0, 0.5); }
}

@keyframes modalFadeOutDown {
    from { background-color: rgba(0, 0, 0, 0.5); opacity: 1; transform: translateY(0); }
    to { background-color: rgba(0, 0, 0, 0); opacity: 0; transform: translateY(20px); }
}

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

@keyframes flashFadeOutShrink {
    to { opacity: 0; transform: scale(0.95); visibility: hidden; }
}

@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fade-dots {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}


/* ===============================
   3. Header
================================= */
.dashboard-header {
    width: 100%;
    padding: 10px 20px;
    height: 60px;
    background-color: #f5f5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    position: relative;
}

.logo-link {
    text-decoration: none;
    color: inherit;
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.logo-main {
    font-family: 'Bowlby One', sans-serif;
    font-size: 24px;
    background: linear-gradient(270deg, #ff7e5f, #ffa159, #2d77ff, #5151ff, #ff98b7, #14dd97, #0e76ff, #e94057);
    background-size: 800% 800%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-animation 15s ease infinite;
}

.logo-sub {
    font-size: 12px;
    color: #555;
    margin-top: 2px;
}

.header-left strong {
    font-size: 22px;
    color: #333;
}

.dashboard-header .dropdown {
    position: relative;
    display: inline-block;
}

.dashboard-header .dropdown {
    position: relative;
    display: inline-block;
    z-index: 1000; /* Ensure dropdown container is above other elements */
}

.dashboard-header .dropdown-toggle {
    cursor: pointer;
    padding: 10px 15px;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-weight: 500;
    color: #343a40;
    transition: all 0.2s ease;
    z-index: 1002; /* Always above the menu */
    position: relative; /* Needed for z-index to work */
}

.dashboard-header .dropdown-toggle .user-greeting {
    line-height: 1;
    vertical-align: middle;
}



.dashboard-header .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 8px;
    background-color: #fff;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1001; /* Lower than toggle, but higher than other content */
    border-radius: 0px 0px 5px 5px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    padding: 10px;
}

.dashboard-header .dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0); /* Slide down to original position */
}

.dashboard-header .dropdown-menu form {
    margin-bottom: 5px; /* Add spacing between button forms */
}

.dashboard-header .dropdown-menu form:last-child {
    margin-bottom: 0; /* Remove margin from the last form */
}

.dashboard-header .dropdown-menu button {
    color: #343a40;
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.dashboard-header .dropdown-menu button:hover {
    background-color: #f1f1f1;
}

.dashboard-header .dropdown-menu .logout-btn {
    background-color: #f8d7da; /* Light red background */
    color: #dc3545; /* Red text color */
}

.dashboard-header .dropdown-menu .logout-btn:hover {
    background-color: #dc3545; /* Darker red background on hover */
    color: #fff; /* White text on hover */
}

.early-adopter-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 0.5rem;
  text-align: center;
  font-weight: 600;
  vertical-align: middle;
  margin-right: 0.5rem;
  font-size: 0.7rem;
  background: linear-gradient(90deg, #CEA119 0%, #FFCC00 50%, #CEA119 100%);
  background-size: 200% 100%;
  border: 2px solid #FFCC00;
  animation: shimmer 8s infinite linear;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right.dropdown {
  display: flex;
  align-items: center;
}

.mobile-header {
    display: none;
    justify-content: center;
    align-items: center;
    height: 60px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    user-select: none;
}

.mobile-header .logo-main {
    font-size: 32px;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 0.25px white;
}


/* ===============================
   4. Forms & Buttons
================================= */
.form-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
button {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    text-align: center;
}

button, .btn {
    background-color: #1f6feb;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

button:hover, .btn:hover {
    background-color: #1a5bbd;
}

.submit-button {
    width: 100%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 16px;
    margin-top: 0.5rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.submit-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}
.submit-button:disabled {
    background: linear-gradient(135deg, #a7adec, #c4a7f5);
    cursor: not-allowed;
    opacity: 0.7;
}

.cancel-button {
    background: #e9ecef;
    border: 1px solid #ced4da;
    color: #495057;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
}
.cancel-button:hover {
    background-color: #dee2e6;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.confirm-button {
    background: linear-gradient(135deg, #1f6feb 0%, #1a5bbd 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 4px 10px rgba(94, 114, 228, 0.2);
    transition: all 0.2s ease;
}
.confirm-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #1a5bbd 0%, #3d4ea3 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(94, 114, 228, 0.3);
}
.confirm-button:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-danger {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

.btn-danger:hover {
    background-color: #d9534f;
    color: white;
    border-color: #d43f3a;
}

.btn-danger-modal {
    background-color: #d9534f;
    color: white;
    border-color: #d43f3a;
    min-height: 50px; /* Ensure consistent height */
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-danger-modal:hover {
    background-color: #c82333;
    border-color: #bd2130;
    color: white;
}

.btn-danger-modal:disabled {
    background-color: #f5c6cb;
    color: #721c24;
    cursor: not-allowed;
    border-color: #f5c6cb;
}

.btn-danger-modal {
    transition: all 0.2s ease-in-out;
}

/* ===============================
   5. Reusable Components
================================= */
.badge {
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
    color: white;
    font-weight: 600;
    display: inline-block;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-low { background-color: #28a745; }
.badge-medium { background-color: #ffc107; color: #343a40; }
.badge-high { background-color: #dc3545; }

.switcher-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    background-color: #e9ecef;
    border-radius: 8px;
    padding: 5px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}
.switcher-container.header {
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.switcher-btn {
    padding: 8px 20px;
    margin: 0 3px;
    border: none;
    background-color: transparent;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    outline: none;
}
.switcher-btn:hover { background-color: #dee2e6; color: #343a40; }
.switcher-btn.active { background-color: #ffffff; color: #1f6feb; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); }


/* ===============================
   6. Modals
================================= */
.modal {
    position: fixed;
    z-index: 1050;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(-30px);
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.modal.show .modal-content { transform: translateY(0); }

.modal-header {
    background-color: #f8f9fa;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333333;
    margin: 0;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0.25rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.close-button:hover { background-color: #e9ecef; color: #333333; }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    /* flex-grow: 1; is part of a flex layout which is now more specific */
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem 1.5rem;
}


/* ===============================
   7. Flash Messages & Spinners
================================= */
.flash-container, #global-flash-container {
    position: fixed;
    top: 70px; /* Under header + 10px margin */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: auto; /* Allow width to be content-driven */
    max-width: 400px; /* Keep a reasonable max-width */
    pointer-events: none; /* Allow clicks through to content below */
    text-align: center; /* Center the text within the flash message */
}
.flash, .form-flash {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(-10px); /* Animate from -10px Y */
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Removed min-width to allow content-driven width */
    user-select: none;
    pointer-events: auto; /* Re-enable pointer events for the message itself */
    display: inline-block; /* Allow width to shrink to content */
    word-wrap: break-word; /* Ensure long words wrap */
    overflow-wrap: break-word; /* Ensure long words wrap */
}
.flash.show, .form-flash.show {
    opacity: 1;
    transform: translateY(0); /* Animate to 0px Y */
}
.flash.success, .form-flash.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash.error, .form-flash.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash.info { background-color: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
.loading-spinner-small {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
}
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
}
.dot {
    width: 10px;
    height: 10px;
    background-color: #1f6feb;
    border-radius: 50%;
    margin: 0 4px;
    animation: fade-dots 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }


/* ===============================
   8. Scrollbar Styles
================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
    border: 2px solid #f1f1f1;
}
::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ===============================
   9. Responsive
================================= */
@media (max-width: 768px) {
    .dashboard-header { display: none !important; }
    .mobile-header { display: flex; }
    .main-content { padding-top: 60px !important; }
    .form-container { width: 90%; }
}