/* ===== GLOBAL & VARIABLES ===== */
:root {
   --background: #cdcdcd;
   --calc-bg: #f4f0f0;
   --btn-bg: #d0abdd;
   
   --btn-hover: #d8c4e0;
   --op-bg: #8c6a8c;
   
   --clear-bg: #b63cc8;
   
   --equal-bg: #c25490;
   
   --text-color: #000000;
   --display-bg: #bcabb0;
   --display-text: #000000;
}

body.dark {
   --background: #2c2c2e;
   --calc-bg: #1c1c1e;
   --btn-bg: #2a2a3c;
   --btn-hover: #48484a;
   --op-bg: #636366;
   --clear-bg: #ff3b30;
   --equal-bg: #5856d6;
   --text-color: #ffffff;
   --display-bg: #000000;
   --display-text: #ffffff;
}

body {
   margin: 0;
   font-family: Arial, sans-serif;
   background: var(--background);
   display: flex;
   justify-content: center;
   align-items: center;
   height: 100vh;
   transition: 0.3s ease;
}

/* ===== RGB HALO BORDER ===== */
.rgb-border {
   padding: 6px;
   border-radius: 30px;
   background: linear-gradient(270deg, #ff0000, #00ff00, #0000ff, #ff00ff);
   background-size: 400% 400%;
   animation: rgbRotate 5s linear infinite;
}

@keyframes rgbRotate {
   0% {
      background-position: 0% 50%;
   }

   50% {
      background-position: 100% 50%;
   }

   100% {
      background-position: 0% 50%;
   }
}

/* ===== CALCULATOR BODY ===== */
.calculator {
   padding: 25px;
   width: 360px;
   background: var(--calc-bg);
   border-radius: 25px;
   box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
   position: relative;
}

/* ===== DISPLAY ===== */
.display input {
   width: 100%;
   padding: 20px;
   font-size: 32px;
   background: var(--display-bg);
   color: var(--display-text);
   border: none;
   border-radius: 15px;
   text-align: right;
   margin-bottom: 20px;

   box-sizing: border-box;
}

/* ===== BUTTON GRID ===== */
.buttons {
   display: grid;
   grid-template-columns: repeat(4, 1fr);

   gap: 12px;
}

.btn {
   aspect-ratio: 1/1;
   
   font-size: 22px;
   color: var(--text-color);
   border: none;
   border-radius: 50%;
   
   background: var(--btn-bg);
   cursor: pointer;
   transition: 0.2s;
   display: flex;
   justify-content: center;
   align-items: center;
}

.btn:hover {
   filter: brightness(0.9);
   transform: scale(1.05);
}

.op {
   background: var(--op-bg);
   color: #fff;
}

.clear {
   background: var(--clear-bg);
   color: #fff;
}

.equal {
   background: var(--equal-bg);
   color: #fff;
}

/* ===== THEME TOGGLE SWITCH ===== */
.toggle {
   width: 50px;
   height: 26px;
   background: #ccc;
   border-radius: 20px;
   position: relative;
   margin: 0 auto 15px;
   cursor: pointer;
   transition: 0.3s;
}

.toggle::before {
   content: "🌙";
   position: absolute;
   width: 20px;
   height: 20px;
   background: white;
   border-radius: 50%;
   top: 3px;
   left: 4px;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 12px;
   transition: 0.3s;
}

body.dark .toggle {
   background: #4cafeb;
}

body.dark .toggle::before {
   left: 26px;
   content: "☀️";
}

/* ===== HISTORY PANEL ===== */
.history-panel {
   position: fixed;
   right: -320px;
   top: 0;
   width: 300px;
   height: 100%;
   background: #1e1e2f;
   color: #fff;
   padding: 20px;
   transition: 0.4s ease;
   z-index: 999;
   box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
}

.history-panel.open {
   right: 0;
}

.history-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   border-bottom: 1px solid #444;
   padding-bottom: 10px;
}

#historyList {
   list-style: none;
   padding: 0;
   margin-top: 20px;
   overflow-y: auto;
   max-height: 80vh;
}

#historyList li {
   padding: 12px;
   border-bottom: 1px solid #333;
   cursor: pointer;
   font-size: 14px;
}

#historyList li:hover {
   background: rgba(255, 255, 255, 0.1);
}

.history-toggle {
   position: fixed;
   bottom: 20px;
   right: 20px;
   width: 55px;
   height: 55px;
   border-radius: 50%;
   background: linear-gradient(45deg, #4cafeb, #ff4d6d);
   color: white;
   border: none;
   font-size: 24px;
   cursor: pointer;
   box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
   z-index: 1000;
}

/* Animations */
.remove {
   animation: removeItem 0.3s forwards;
}

@keyframes removeItem {
   to {
      opacity: 0;
      transform: translateX(40px);
   }
}

/* Responsive */
@media (max-width: 400px) {
   .calculator {
      width: 90%;
   }

   .btn {
      font-size: 18px;
   }
}

/* ===== RESPONSIVE UPDATES ===== */

@media (max-width: 480px) {
   .history-panel {
      width: 100%;
      right: -100%;
      
      box-shadow: none;
   }

   .history-panel.open {
      right: 0;
   }

   .history-toggle {
      width: 50px;
      height: 50px;
      bottom: 15px;
      right: 15px;
      font-size: 20px;
   }


   #historyList li {
      font-size: 16px;
      padding: 15px;
   }

   .calculator {
      width: 95%;
      padding: 15px;
   }
}
@media (min-width: 481px) and (max-width: 1024px) {
   .history-toggle {
      bottom: 25px;
      right: 25px;
   }
}

/* ===== MOBILE RESPONSIVE STYLES ===== */
/* ===== মোবাইল রেসপনসিভ ডিজাইন ===== */
@media (max-width: 480px) {
   .calculator {
      width: 95vw;
      
      max-width: 350px;
      padding: 15px;
   }

   .display input {
      font-size: 28px;
      
      padding: 15px;
      margin-bottom: 15px;
   }

   .buttons {
      gap: 8px;
      
   }

   .btn {
      font-size: 18px;
      
   }


   .history-panel {
      width: 100%;
      right: -100%;
   }

   .history-panel.open {
      right: 0;
   }

   .btn::before {
      inset: -2px;
   }
}

@media (max-width: 320px) {
   .calculator {
      padding: 10px;
   }

   .btn {
      font-size: 16px;
   }
}

* {
   box-sizing: border-box;
   margin: 0;
   padding: 0;
}

/* ===== History Panel (Fixed) ===== */
.history-panel {
   position: fixed;
   right: -320px;
   top: 0;
   width: 300px;
   height: 100%;
   background: rgba(30, 30, 47, 0.95);
   
   backdrop-filter: blur(10px);
   
   color: #fff;
   padding: 20px;
   transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
   z-index: 2000;
   
   box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
   border-left: 2px solid #4cafeb;
}

/* ===== History Button Mobile Responsive ===== */
@media (max-width: 480px) {
   #historyToggle {
      position: fixed;
      bottom: 20px;
      right: 20px;
      width: 52px;
      height: 52px;
      border-radius: 50%;
      font-size: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 3000;
      box-shadow: 0 5px 12px rgba(0, 0, 0, 0.35);
   }
}

.history-panel.open {
   right: 0;
}


@media (max-width: 480px) {
   .history-panel {
      width: 85%;
      right: -85%;
   }

   .history-panel.open {
      right: 0;
   }
}


#historyList li {
   background: rgba(255, 255, 255, 0.05);
   margin-bottom: 10px;
   border-radius: 8px;
   padding: 12px;
   border-bottom: none;
   
}

/* History action buttons */
#clearHistory,
#closeHistory {
   width: 44px;
   height: 44px;
   font-size: 20px;
   border: none;
   border-radius: 50%;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   background: #2c2c2c;
   color: #fff;
   transition: all 0.25s ease;
}

/* Hover effect */
#clearHistory:hover {
   background: #ff4d4d;
}

#closeHistory:hover {
   background: #555;
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 600px) {

   #clearHistory,
   #closeHistory {
      width: 38px;
      height: 38px;
      font-size: 18px;
   }
}

.history-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 10px;
}

/* ============================================================
   FINAL MOBILE RESPONSIVE OPTIMIZATION 
   ============================================================ */

@media (max-width: 480px) {

   
   .calculator {
      width: 92vw;
      max-width: 350px;
      padding: 15px;
   }

   
   .display input {
      font-size: 28px;
      padding: 15px;
      margin-bottom: 15px;
   }

   
   .buttons {
      gap: 8px;
   }

   .btn {
      font-size: 18px;
   }

   
   .history-toggle,
   #historyToggle {
      width: 45px;
      height: 45px;
      bottom: 15px;
      right: 15px;
      font-size: 20px;
      z-index: 3000;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
   }

   
   .history-panel {
      width: 85%;
      right: -85%;
      
      border-left: 2px solid #4cafeb;
   }

   .history-panel.open {
      right: 0;
   }

  
   #historyList li {
      font-size: 15px;
      padding: 15px;
      margin-bottom: 8px;
   }


   #clearHistory,
   #closeHistory {
      width: 38px;
      height: 38px;
      font-size: 18px;
   }
}
@media (max-width: 330px) {
   .calculator {
      padding: 10px;
   }

   .btn {
      font-size: 16px;
   }

   .display input {
      font-size: 24px;
   }
}