/* =============================
   1. Imports & Variables
   ============================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&family=Roboto+Mono:wght@500&display=swap');

:root {
  /* Light Theme Palette */
  --primary: #10b981;        /* Modern Emerald */
  --primary-dark: #059669;
  --accent: #3b82f6;         /* Blue */
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --bg-sidebar: #1f2937;
  --text-main: #1f2937;
  --text-light: #f9fafb;
  --border: #e5e7eb;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-header: 0 4px 20px rgba(0,0,0,0.05);
}

body.dark-mode {
  /* Dark Theme Palette */
  --bg-body: #111827;
  --bg-card: #1f2937;
  --bg-sidebar: #0f172a;
  --text-main: #f3f4f6;
  --border: #374151;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

/* =============================
   2. Global Reset & Body
   ============================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: grid;
  grid-template-areas: 
    "sidebar header"
    "sidebar main"
    "sidebar footer";
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  background: var(--bg-body);
  color: var(--text-main);
}

/* =============================
   3. Header
   ============================= */
header {
  grid-area: header;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: var(--bg-card);
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-header);
  z-index: 10;
}

header h1, header div {
  font-weight: 600;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header { color: var(--text-main); } 

/* Theme Toggle */
.theme-toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}
.theme-toggle input { display: none; }
.theme-toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  border-radius: 34px;
  transition: 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.theme-toggle .slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 4px; bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.theme-toggle input:checked + .slider { background-color: var(--primary); }
.theme-toggle input:checked + .slider:before { transform: translateX(24px); }

/* =============================
   4. Sidebar
   ============================= */
aside {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  padding: 25px 15px;
  gap: 12px;
  box-shadow: 4px 0 15px rgba(0,0,0,0.05);
  z-index: 5;
}

aside button {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: #9ca3af;
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.95rem;
  text-align: left;
}

aside button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(5px);
}

aside button.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

aside button i { width: 20px; text-align: center; font-size: 1.1rem; }

/* =============================
   5. Main Content Area (Cards)
   ============================= */
main {
  grid-area: main;
  padding: 40px 20px;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.calculator, .currency-converter, .unit-converter, .number-system-converter {
  width: 100%;
  max-width: 420px;
  padding: 30px;
  background: var(--bg-card);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  transition: transform 0.3s;
}

/* =============================
   6. Calculator Styles
   ============================= */
.display {
  width: 100%;
  height: 80px;
  background: var(--bg-body);
  border-radius: 16px;
  margin-bottom: 25px;
  padding: 15px 20px;
  font-family: 'Roboto Mono', monospace;
  font-size: 2rem;
  color: var(--text-main);
  text-align: right;
  overflow-x: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
body.dark-mode .display {
  background: #111827;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

/* =============================
   7. Currency Converter Specifics
   ============================= */

.currency-card {
  padding: 28px;
  background: var(--bg-card);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  animation: fadeIn 0.4s ease;
  transition: all 0.25s ease;
}

.currency-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.10);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.field-row {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.field-row select,
.field-row input {
  flex: 1;
}
#convertBtn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader {
  width: 18px;
  height: 18px;
  border: 3px solid transparent;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}
.loading .btn-text { display: none; }
.loading .loader { display: inline-block; }


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

.loading .btn-text {
  display: none;
}

.loading .loader {
  display: inline-block;
}


/* Style the Select Dropdowns */
.currency-converter select {
  height: 50px;
  background-color: var(--bg-body);
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 15px;
}


.currency-converter button {
  width: 100%;
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  padding: 18px;
  margin-top: 10px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}
.currency-converter button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

/* =============================
   8. Global Inputs & Buttons
   ============================= */
/* Base Input Styles */
input, select {
  width: 100%;
  padding: 12px 15px;
  margin: 10px 0 20px 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text-main);
  outline: none;
  font-size: 1rem;
  transition: all 0.2s;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Grid for Calculator Buttons */
.buttons, .buttons-6col {
  display: grid;
  gap: 12px;
}
.buttons { grid-template-columns: repeat(4, 1fr); }
.buttons-6col { grid-template-columns: repeat(6, 1fr); }

/* Base Button Styles */
button {
  padding: 15px;
  font-size: 1.1rem;
  font-weight: 500;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: var(--bg-body);
  color: var(--text-main);
  box-shadow: 0 4px 0 rgba(0,0,0,0.05);
  transition: all 0.1s;
  user-select: none;
}

button:active { transform: translateY(4px); box-shadow: none; }
button:hover { filter: brightness(0.97); }
body.dark-mode button:hover { filter: brightness(1.2); }

/* Optional Helper Classes */
.btn-equal { background: var(--primary); color: white; box-shadow: 0 4px 0 var(--primary-dark); }
.btn-operator { color: var(--primary); background: rgba(16, 185, 129, 0.1); }

/* =============================
   9. Footer & Responsive
   ============================= */
footer {
  grid-area: footer;
  text-align: right;
  padding: 15px;
  background: var(--bg-card);
  color: #6b7280;
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  body {
    grid-template-areas: "header" "main" "sidebar";
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  header { padding: 10px 20px; }
  
  aside {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
    position: sticky;
    bottom: 0;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    order: 3;
  }
  aside button {
    flex: 0 0 auto;
    margin: 0 5px;
    padding: 10px 15px;
    font-size: 0.8rem;
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
  aside button:hover { transform: none; }
  footer { display: none; }
  
  .calculator, .currency-converter { padding: 20px; }
  .buttons { gap: 8px; }
  button { padding: 12px; font-size: 1rem; }
}
/*Result Box — Match Input Style */
#num-result {
  width: 100%;
  padding: 14px 18px;
  margin-top: 20px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

#unit-result {
  width: 100%;
  padding: 14px 18px;
  margin-top: 20px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
#result {
  width: 100%;
  padding: 14px 18px;
  margin-top: 20px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
/* Dark Mode */
body.dark-mode #num-result {
  background: #111827;
  border-color: #374151;
  color: var(--text-main);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}
