/*
================================================================================
|                              DESIGN SYSTEM                                   |
================================================================================
*/

:root {
  /* Color Palette */
  --color-primary: #0d6efd;
  --color-primary-dark: #0b5ed7;
  --color-primary-light: #cfe2ff;
  
  --color-secondary: #6c757d;
  --color-secondary-dark: #5c636a;
  
  --color-success: #198754;
  --color-danger: #dc3545;
  --color-warning: #ffc107;
  --color-info: #0dcaf0;

  /* New Login Accent Color */
  --color-login-accent: #f97316; /* Vibrant Orange */
  --color-login-accent-dark: #ea580c;

  /* Backgrounds */
  --color-bg-dark: #111827;      /* Sidebar */
  --color-bg-dark-card: #1f2937;
  --color-bg-light: #f8f9fa;     /* Main Content BG */
  --color-bg-white: #ffffff;     /* Card BG */
  
  /* Text */
  --color-text-light: #f8f9fa;
  --color-text-dark: #212529;
  --color-text-muted: #6c757d;
  --color-text-on-primary: #ffffff;
  
  /* Borders */
  --color-border-dark: #374151;
  --color-border-light: #dee2e6;
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px 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);
  --shadow-focus: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

/* Base Styles */
body {
  font-family: "Inter", sans-serif;
  background-color: var(--color-bg-light);
  color: var(--color-text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/*
================================================================================
|                         ENHANCED LOGIN SCREEN                                |
================================================================================
*/

/* --- Animated Gradient Background --- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: linear-gradient(-45deg, #4c1d95, #391b10, #1e1b4b, #9f1239);
  background-size: 400% 400%;
  animation: animateGradient 20s ease infinite;
}

@keyframes animateGradient {
	0% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
	100% { background-position: 0% 50%; }
}


/* --- Glassmorphism Card Effect --- */
.login-card {
  display: flex;
  width: 100%;
  max-width: 900px;
  min-height: 550px;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  background: rgba(25, 22, 30, 0.75); /* Darker, slightly purple background */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  animation: fadeInForm 0.8s ease-out forwards;
}

@keyframes fadeInForm {
  from { opacity: 0; transform: translateY(25px); }
  to { opacity: 1; transform: translateY(0); }
}

.illustration-pane {
  flex: 1;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}
@media (min-width: 768px) {
  .illustration-pane { display: flex; }
}

.illustration-pane::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, color-mix(in srgb, var(--color-login-accent) 15%, transparent) , transparent 40%);
  animation: rotateGradient 20s linear infinite;
}

@keyframes rotateGradient {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.illustration-content {
  position: relative;
  animation: floatIllustration 6s ease-in-out infinite;
}

@keyframes floatIllustration {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-15px); }
  100% { transform: translateY(0px); }
}

.illustration-icon-bg {
  font-size: 12rem;
  color: var(--color-login-accent);
  opacity: 0.15;
}
.illustration-icon-fg {
  position: absolute;
  font-size: 4rem;
  color: color-mix(in srgb, var(--color-login-accent) 70%, #fff);
  text-shadow: 0 0 20px color-mix(in srgb, var(--color-login-accent) 50%, transparent);
}
.fa-lock { top: 35%; left: 35%; }
.fa-key { bottom: 10%; right: 10%; transform: rotate(-45deg); }

.form-pane {
  flex: 1;
  padding: 2rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Centered Logo Container */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#login-screen .logo-image {
    width: 60px;
    height: 60px;
    margin-bottom: 0.75rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border-dark);
}

.input-group {
    position: relative;
    margin-bottom: 1.75rem;
    width: 100%; /* Ensure group takes full width */
}

.input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    transition: color 0.3s;
    font-size: 0.875rem;
}

.input-group .form-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border-dark);
    border-radius: 0;
    padding-left: 2.5rem;
    padding-bottom: 0.75rem;
    color: var(--color-text-light);
    font-size: 1rem;
    transition: border-color 0.3s;
    width: 100%;
}

/* --- Animated Input Underline --- */
.input-underline {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background-color: var(--color-login-accent);
  transition: width 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.input-group .form-input:focus {
    outline: none;
    box-shadow: none;
    border-color: transparent;
}
.input-group .form-input:focus ~ .input-underline {
    width: 100%;
}
.input-group .form-input:focus ~ .input-icon {
    color: var(--color-login-accent);
}


.password-toggle {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.3s;
}
.password-toggle:hover {
    color: var(--color-text-light);
}

.btn-login {
  width: 100%;
  padding: 0.8rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-on-primary);
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  background: linear-gradient(45deg, var(--color-login-accent), var(--color-login-accent-dark));
  background-size: 150% 150%;
  transition: all 0.3s ease;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--color-login-accent) 30%, transparent);
  background-position: right center;
}

/*
================================================================================
|                             MAIN APP LAYOUT                                  |
================================================================================
*/

#app-container {
  display: none;
}
#app-container.visible {
  display: flex;
}

/* Sidebar */
.sidebar {
  z-index: 20;
  height: 100vh;
  width: 16rem;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  background-color: var(--color-bg-dark);
  border-right: 1px solid var(--color-border-dark);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-dark);
  color: var(--color-text-light);
}
.sidebar-header-title {
  color: var(--color-text-light);
  text-shadow: 0 0 8px color-mix(in srgb, var(--color-primary) 20%, transparent);
}
.logo-sidebar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 0.75rem;
}

.sidebar-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  color: var(--color-text-muted);
  transition: all 0.2s ease-in-out;
  position: relative;
}

.sidebar-item:hover {
  background-color: var(--color-bg-dark-card);
  color: var(--color-text-light);
  transform: translateX(4px);
}

.sidebar-item.active {
  background-color: var(--color-primary);
  color: var(--color-text-on-primary);
  font-weight: 600;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--color-primary) 30%, transparent);
}
.sidebar-item.active i {
  color: var(--color-text-on-primary);
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem;
  border-top: 1px solid var(--color-border-dark);
}

/* Content Area */
.content-area {
  background-color: var(--color-bg-light);
  color: var(--color-text-dark);
  margin-left: 16rem;
  min-height: 100vh;
  width: calc(100% - 16rem);
}

/*
================================================================================
|                                COMPONENTS                                   |
================================================================================
*/

/* Cards */
.card {
  background-color: var(--color-bg-white);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  border-radius: var(--border-radius-lg);
  transition: all 0.2s ease-in-out;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Stat Cards (Dashboard) */
.stat-card {
  display: flex;
  align-items: center;
  padding: 1.5rem;
  gap: 1.5rem;
}
.stat-card-icon {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}
.stat-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}
.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text-dark);
}

/* Buttons */
.btn {
  padding: 0.6rem 1.25rem;
  border-radius: var(--border-radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-text-on-primary);
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
.btn-secondary {
  background-color: var(--color-bg-white);
  color: var(--color-text-dark);
  border-color: var(--color-border-light);
}
.btn-secondary:hover {
  background-color: var(--color-bg-light);
}
.btn-danger {
  background-color: var(--color-danger);
  color: var(--color-text-on-primary);
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background-color: color-mix(in srgb, var(--color-danger) 85%, black);
}
.btn-success {
  background-color: var(--color-success);
  color: var(--color-text-on-primary);
  border-color: var(--color-success);
}
.btn-excel {
  background-color: #1d6f42;
  color: white;
}
.btn-excel:hover {
  background-color: #15552f;
}

/* Forms */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}
.form-input, .form-select {
  border: 1px solid var(--color-border-light);
  border-radius: var(--border-radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: var(--color-text-dark);
  background-color: var(--color-bg-white);
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.form-input:focus, .form-select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: var(--shadow-focus);
}
.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
}
.table-header {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--color-bg-light);
}
.table-cell {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  white-space: nowrap;
}
tbody tr:hover {
  background-color: var(--color-bg-light);
}
.sortable-header {
  cursor: pointer;
  user-select: none;
}
.sortable-header:hover {
  background-color: color-mix(in srgb, var(--color-border-light) 50%, transparent);
}
.sort-icon {
  display: inline-block;
  width: 1em;
  margin-left: 0.3em;
  color: var(--color-text-muted);
  opacity: 0.5;
  transition: opacity 0.2s ease-in-out;
}
.sortable-header.sort-active .sort-icon {
  opacity: 1;
  color: var(--color-primary);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgb(0 0 0 / 0.5);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-content {
  background-color: var(--color-bg-white);
  margin: 5vh auto;
  padding: 0; /* Remove padding to use header/body/footer */
  border: 1px solid var(--color-border-light);
  width: 90%;
  max-width: 600px;
  border-radius: var(--border-radius-lg);
  position: relative;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.4s ease-out;
}
@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text-dark);
}
.close-button {
  color: #aaa;
  font-size: 1.75rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}
.close-button:hover,
.close-button:focus {
  color: var(--color-text-dark);
}
.modal-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-bg-light);
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Chart Containers */
.chart-container {
  height: 300px;
  width: 100%;
  position: relative;
}

/*
================================================================================
|                               UTILITIES                                      |
================================================================================
*/
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-info { color: var(--color-info); }
.text-muted-text { color: var(--color-text-muted); }
.text-light-text { color: var(--color-text-light); }

.bg-light-background { background-color: var(--color-bg-light); }
.border-light-border { border-color: var(--color-border-light); }

.status-badge {
  padding: 0.25em 0.6em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  text-transform: capitalize;
}
.status-income {
    background-color: color-mix(in srgb, var(--color-success) 15%, transparent);
    color: var(--color-success);
}
.status-expense {
    background-color: color-mix(in srgb, var(--color-danger) 15%, transparent);
    color: var(--color-danger);
}

/*
================================================================================
|                       ENHANCED WELCOME OVERLAY                               |
================================================================================
*/
#welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: linear-gradient(-45deg, #4c1d95, #35180c, #1e1b4b, #9f1239);
    background-size: 400% 400%;
    animation: animateGradient 20s ease infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none;
}

#welcome-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.welcome-content {
    text-align: center;
    color: var(--color-text-light);
}

.welcome-heading {
    font-size: 2.5rem;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    margin: 0;
    transform: translateY(20px);
    opacity: 0;
    animation: slideUpFadeIn 0.8s 0.2s ease-out forwards;
}

.welcome-static-text, .welcome-typed-text {
    display: inline-block; /* Needed for transforms if any */
}

@keyframes slideUpFadeIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (min-width: 768px) {
    .welcome-heading {
        font-size: 4rem;
    }
}

.welcome-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    background-color: var(--color-login-accent);
    margin-left: 8px;
    animation: blink 1s step-end infinite;
    vertical-align: baseline;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.welcome-subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    margin-top: 1rem;
    color: var(--color-text-light);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.welcome-subtitle.visible {
    opacity: 0.8;
    transform: translateY(0);
}

.welcome-loader-container {
    position: absolute;
    bottom: 5%;
    width: 80%;
    max-width: 400px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.welcome-loader-bar {
    width: 0;
    height: 100%;
    background-color: var(--color-login-accent);
    border-radius: 4px;
}

#welcome-overlay.visible .welcome-loader-bar {
    animation: fillLoader 3s ease-out forwards;
}

@keyframes fillLoader {
    from { width: 0%; }
    to { width: 100%; }
}
