/* ========================= GLOBAL ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", Sans-Serif;
}

html, body {
    width: 100dvw;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    background: #000;
}

.calculator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100svh; /* safe viewport height, tetap penuh layar meski keyboard muncul */
    display: flex;
    flex-direction: column;
    background: #000;
    overflow: hidden;
}

.display-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 20px;
    position: relative;
}

.input-display {
    font-size: 3rem;
    color: #fff;
    width: 100%;
    text-align: right;
    overflow-wrap: break-word;
}

.input-small {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.8);
}

.result-display {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.5);
    transition: all 0.2s ease;
    width: 100%;
    text-align: right;
    overflow-wrap: break-word;
}

.result-normal {
    font-size: 3rem;
    color: #fff;
    opacity: 1;
}

/* ========================= BUTTONS ========================= */
.buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 1fr; /* <--- tambahkan ini */
    gap: 10px;
    padding: 10px;
    box-sizing: border-box;
}

.buttons button,
.basic-mode button,
.sci-mode button {
    width: 100%;
    height: 100%;          /* <--- ganti aspect-ratio */
    border-radius: 50%;    /* bulat sempurna */
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn {
    aspect-ratio: 1/1;
    border-radius: 50%;
    border: none;
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.1s ease, color 0.2s;
    overflow: hidden;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:active {
    transform: scale(0.95);
    filter: none;
    box-shadow: none;
}

/* Tombol angka normal */
.white { 
    color: #fff; 
    background: #111; 
}


.calculated .btn.white { color: #fff; background: #111; }

/* Superscript khusus untuk 1/x */
button[data-val="1/x"] {
    font-size: 1.2rem;
}

button[data-val="1/x"] sup {
    font-size: 0.6em;
    vertical-align: super;
}

/* ========================= MENU ========================= */
.menu-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    font-size: 1.6rem;
    background: #111;   /* dark mode */
    color: #fff;
    border: none;

    width: 45px;
    height: 45px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;

    /* ===== FIX TOUCH BULAT ===== */
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.menu-btn:active {
    transform: scale(0.9);
}

/* ===== LIGHT MODE FIX ===== */
body.light .menu-btn {
    background: #eee !important;  /* bulat putih */
    color: #000 !important;       /* icon hitam */
}

/* ========================= SIDEBAR ========================= */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 300px;
    height: 100%;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 20px;
    transition: left 0.3s ease, background 0.3s ease;
    z-index: 20;
    text-align: center;
}

.sidebar.open { left: 0; }
.sidebar h2 { margin-bottom: 10px; }
.sidebar p { margin-bottom: 20px; }
.sidebar hr { margin: 20px 0; border: 0; border-top: 1px solid rgba(255,255,255,0.2); }

body.light .sidebar {
    background: #eee;
    color: #000;
}

.sidebar-footer { text-align: center; font-size: 0.75rem; color: inherit; margin-top: 20px; }

.social-icons { display: flex; justify-content: center; gap: 15px; margin-bottom: 10px; }
.social-icons a { 
    display: inline-flex; 
    justify-content: center; 
    align-items: center; 
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    overflow: hidden; 
    text-decoration: none; 
    -webkit-tap-highlight-color: transparent; 
    touch-action: manipulation;
}
.social-icons a svg { width: 70%; height: 70%; }

/* ========================= THEME TOGGLE ========================= */
.theme-toggle { display: flex; justify-content: center; align-items: center; margin-top: 15px; }

.toggle-wrapper { 
    display: inline-block; 
    cursor: pointer; 
    width: 60px; 
    height: 30px; 
    position: relative; 
    border-radius: 30px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent; 
    touch-action: manipulation;
}

.toggle {  
    position: relative;  
    width: 100%;  
    height: 100%;  
    border-radius: 30px;  
    display: flex;  
    align-items: center;  
    justify-content: space-between;  
    padding: 0 5px;  
    box-sizing: border-box;  
    transition: background 0.3s ease;  
}

.toggle .icon { width: 18px; height: 18px; z-index: 1; transition: opacity 0.3s ease; }
.social-icons a svg { width: 70%; height: 70%; }  

body:not(.light) .facebook-icon svg circle { fill: #fff; }  
body:not(.light) .facebook-icon svg path   { fill: #000; }  
body:not(.light) .github-icon svg circle   { fill: #000; }  
body:not(.light) .github-icon svg path     { fill: #fff; }  
body:not(.light) .telegram-icon svg circle { fill: #000; }  
body:not(.light) .telegram-icon svg path   { fill: #fff; }  

body.light { background: #fff; color: #000; }  
body.light .calculator { background: #fff; }  
body.light .white { color: #000; background: #eee; }  
body.light .cyan,  
body.light .operator,  
body.light .equals,  
body.light #clear,  
body.light #delete { color: #fff; background: #000; }  
body.light #inputDisplay, body.light #resultDisplay { color: #000; }  
body.light .input-small { color: rgba(0,0,0,0.8); }  
body.light .result-display { color: rgba(0,0,0,0.5); }  
body.light .result-normal { color: #000; }  
body.light .menu-btn { color: #000; }  
body.light .sidebar { background: #fff; color: #000; }  
body.light .sidebar hr { border-top-color: rgba(0,0,0,0.2); }  
body.light .facebook-icon svg circle { fill: #000; }  
body.light .facebook-icon svg path   { fill: #fff; }  
body.light .github-icon svg circle   { fill: #fff; }  
body.light .github-icon svg path     { fill: #000; }  
body.light .telegram-icon svg circle { fill: #fff; }  
body.light .telegram-icon svg path   { fill: #000; }

.toggle .sun { fill: #000; opacity: 1; transition: opacity 0.3s ease, fill 0.3s ease; }   
.toggle .moon { fill: #fff; opacity: 1; transition: opacity 0.3s ease, fill 0.3s ease; }  

.toggle .handle {  
    position: absolute;  
    top: 3px;  
    left: 3px;  
    width: 24px;  
    height: 24px;  
    border-radius: 50%;  
    transition: transform 0.3s ease, background 0.3s ease;  
    z-index: 2;  
}

.toggle-wrapper input { display: none; }  
.toggle-wrapper input:checked + .toggle .handle { transform: translateX(30px); }

/* ========================= LIGHT / DARK MODE ========================= */
body:not(.light) .toggle { background: #fff; } 
body:not(.light) .toggle .handle { background: #000; }  
body:not(.light) .toggle .moon { opacity: 1; }          
body:not(.light) .toggle .sun  { opacity: 0.3; }       

body.light .toggle { background: #000; }               
body.light .toggle .handle { background: #fff; }       
body.light .toggle .sun  { opacity: 1; }               
body.light .toggle .moon { opacity: 0.3; }             

body.light { background: #fff; color: #000; }  
body.light .calculator { background: #fff; }  
body.light .white { color: #000; background: #eee; }  
body.light .cyan, body.light .operator, body.light .equals, body.light #clear, body.light #delete, 
body.light #clear-basic, body.light #delete-basic,
body.light .basic-mode .operator, body.light .basic-mode .equals, body.light .basic-mode button[data-val="swap"],
body.light .sci-mode .operator, body.light .sci-mode .equals, body.light .sci-mode button[data-val="swap"] {
    color: #fff; background: #000; 
}  
body.light #inputDisplay, body.light #resultDisplay { color: #000; }  
body.light .input-small { color: rgba(0,0,0,0.8); }  
body.light .result-display { color: rgba(0,0,0,0.5); }  
body.light .result-normal { color: #000; }  
body.light .menu-btn { color: #000; }  
body.light .sidebar hr { border-top-color: rgba(0,0,0,0.2); }

/* ========================= SCIENTIFIC MODE ========================= */
.sci { display: flex; }  
.calculator.basic .sci { display: none !important; }

/* ========================= BASIC MODE 5x4 ========================= */
.basic-mode {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr; /* <--- ganti grid-template-rows */
    gap: 10px;
    padding: 10px;
}

.basic-mode .btn {
    border-radius: 50%;  
    font-size: 1.6rem;
    aspect-ratio: 1/1;
}

/* ========================= DIVIDER ========================= */
.divider {
    border: none;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
    margin: 0 10px;
}

body.light .divider {
    border-top-color: rgba(0, 0, 0, 0.2);
}
/* ========================= MINI BUTTONS ========================= */
/* Tombol scientific / simbol khusus lebih kecil */
.btn-mini {
    font-size: 1.2rem;
}

.btn-mini sup,
.btn-mini sub,
.btn-mini span.top,
.btn-mini span.bottom {
    font-size: 0.6em;
    line-height: 1;
    vertical-align: super; /* sub bisa disesuaikan jika perlu */
}

/* Tombol mini spesifik scientific / simbol */
button[data-val="1/x"], 
button[data-val="x^y"], 
button[data-val="√"], 
button[data-val="pi"], 
button[data-val="sin"], 
button[data-val="cos"], 
button[data-val="tan"], 
button[data-val="lg"], 
button[data-val="ln"], 
button[data-val="2nd"], 
button[data-val="deg"], 
button[data-val="("], 
button[data-val=")"] {
    font-size: 1.2rem;
    opacity: 0.6;
}

button[data-val="x!"] {
    font-size: 1.0rem;
    opacity: 0.6;
}

/* Hanya 1/x dan x^y yang pakai flex column top/bottom */
button[data-val="1/x"],
button[data-val="x^y"] {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

button[data-val="1/x"] span.top,
button[data-val="x^y"] span.top {
    font-size: 0.6em;
    line-height: 1;
}

button[data-val="1/x"] span.bottom,
button[data-val="x^y"] span.bottom {
    font-size: 0.6em;
    line-height: 1;
}
//* ========================= SCI MODE DARK ========================= */
body:not(.light) .sci-mode button {
    background: #000; /* default background hitam */
    color: #fff;      /* default teks putih */
}

/* Tombol tanpa background, teks cyan */
body:not(.light) .sci-mode #clear,
body:not(.light) .sci-mode #delete,
body:not(.light) .sci-mode button[data-val="%"],
body:not(.light) .sci-mode button[data-val="/"],
body:not(.light) .sci-mode button[data-val="*"],
body:not(.light) .sci-mode button[data-val="-"],
body:not(.light) .sci-mode button[data-val="+"] {
    background: #111 !important;
    color: #00ffff !important; /* cyan text */
}

/* Tombol dengan background cyan, text putih */
body:not(.light) .sci-mode button[data-val="swap"],
body:not(.light) .sci-mode #equals {
    background: #00ffff !important; /* cyan background */
    color: #000 !important;         /* teks hitam agar kontras */
}
/* ========================= BASIC MODE DARK ========================= */
body:not(.light) .basic-mode button {
    background: #111; /* default background gelap */
    color: #fff;      /* default teks putih */
}

/* Tombol tanpa background, text cyan */
body:not(.light) .basic-mode #clear-basic,
body:not(.light) .basic-mode #delete-basic,
body:not(.light) .basic-mode button[data-val="%"],
body:not(.light) .basic-mode button[data-val="/"],
body:not(.light) .basic-mode button[data-val="*"],
body:not(.light) .basic-mode button[data-val="-"],
body:not(.light) .basic-mode button[data-val="+"] {
    background: #111 !important;
    color: #00ffff !important; /* cyan text */
}

/* Tombol dengan background cyan, text hitam */
body:not(.light) .basic-mode button[data-val="swap"],
body:not(.light) .basic-mode #equals-basic {
    background: #00ffff !important; /* cyan background */
    color: #000 !important;         /* teks hitam */
}

/* Tombol angka normal tetap putih pada dark mode */
body:not(.light) .basic-mode .white {
    background: #111 !important;
    color: #fff !important;
}
/* ========================= SCIENTIFIC MODE LIGHT ========================= */
body.light .sci-mode button {
    background: #eee; /* default background angka */
    color: #000;      /* default text hitam */
}

/* Tombol tanpa background, text hitam */
body.light .sci-mode #clear,
body.light .sci-mode #delete,
body.light .sci-mode .operator {
    background: #eee !important;
    color: #000 !important; /* hitam text */
}

/* Tombol dengan background hitam, text putih */
body.light .sci-mode button[data-val="swap"],
body.light .sci-mode #equals {
    background: #000 !important; /* background hitam */
    color: #fff !important;      /* text putih */
}

/* Tombol angka normal tetap background putih / text hitam */
body.light .sci-mode .white {
    background: #eee !important;
    color: #000 !important;
}
/* Semua tombol tetap lingkaran */
.btn, .basic-mode .btn, .sci-mode .btn {
    border-radius: 50%;
    aspect-ratio: 1/1;
}
/* ========================= BASIC MODE LIGHT ========================= */
body.light .basic-mode button {
    background: #eee; /* default background angka */
    color: #000;      /* default text hitam */
}

/* Tombol tanpa background, text putih (sebelumnya cyan di dark mode) */
body.light .basic-mode #clear-basic,
body.light .basic-mode #delete-basic,
body.light .basic-mode button[data-val="%"],
body.light .basic-mode button[data-val="/"],
body.light .basic-mode button[data-val="*"],
body.light .basic-mode button[data-val="-"],
body.light .basic-mode button[data-val="+"] {
    background: #eee !important;
    color: #000 !important; /* hitam text */
}
/* khusus 2nd dan deg */
.btn[data-val="2nd"].locked,
.btn[data-val="deg"].locked {
    opacity: 0.3;
    cursor: not-allowed;
}
/* ========================= FEEDBACK BOX ========================= */
.feedback-box {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 15px;
}

.feedback-label {
    font-weight: 500;
}

#feedbackInput {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    resize: vertical;
    box-sizing: border-box;
}

/* Char count di luar textarea, tetap di kanan */
.char-count {
    font-size: 0.8rem;
    color: #555;
    text-align: right;
}

/* DEFAULT DARK MODE */
.feedback-btn {
    align-self: center;        /* tombol di center */
    padding: 8px 16px;         /* padding horizontal menyesuaikan text */
    border: none;
    border-radius: 5px;
    background-color: #00ffff; /* cyan untuk dark mode */
    color: #000;
    cursor: pointer;
    transition: background 0.2s;
}

.feedback-btn:hover {
    background-color: #00cccc; /* hover lebih gelap */
}

/* FEEDBACK MESSAGE */
.feedback-message {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #0a7d00;
}

/* ========================= LIGHT MODE ========================= */
body.light .feedback-btn {
    background-color: #000;
    color: #fff;
}

body.light .feedback-btn:hover {
    background-color: #222;
}
