:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #7209b7;
    --accent: #f72585;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --success: #4cc9f0;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

.dark-mode {
    --primary: #4895ef;
    --primary-dark: #3f7fd5;
    --secondary: #b5179e;
    --accent: #f72585;
    --light: #121212;
    --dark: #f8f9fa;
    --gray: #adb5bd;
    --card-bg: rgba(30, 30, 40, 0.95);
    --card-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

app {
    font-family: 'Inter', sans-serif;
    background: rgb(88, 88, 249);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    color: var(--dark);
    transition: var(--transition);
    -webkit-text-size-adjust: 100%;
}

/* Header */
.site-header {
    width: 100%;
    background-color: rgb(88, 88, 249);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 20px;
    border-bottom: white 1px solid;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 40px;
    margin-right: 10px;
    object-fit: cover;
    position: relative;
    top: 2px;
    filter: drop-shadow(0 0 3px rgb(255, 255, 255));
}

.logo a span {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: bolder;
    background: linear-gradient(to right, #aa00ff, #0015ff, #1b9400, #ffae00, #ff0000, #ffae00, #1b9400, #0015ff, #aa00ff);
    background-size: 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: animate-gradient 2.5s linear infinite;
}

@keyframes animate-gradient {
    to {
        background-position: 200%;
    }
}

.logo a {
    text-decoration: none;
    color: white;
}

.nav-links a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-size: 1rem;
    font-weight: bold;
}

.nav-links a:hover {
    text-decoration: underline;
    color: aqua;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    padding-top: 10px;
}

header h1 {
    color: white;
    font-size: clamp(1.8rem, 4vw, 3.8rem);
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    letter-spacing: -0.5px;
}

header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(0.95rem, 2vw, 1.3rem);
    max-width: 700px;
    margin: 0 auto 20px;
    font-weight: 300;
    padding: 0 10px;
}

.calculator-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
}

@media (min-width: 992px) {
    .calculator-container {
        flex-direction: row;
        align-items: flex-start;
    }

    .shape-selector {
        position: sticky;
        top: 20px;
    }
}

.shape-selector {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border-radius: 25px;
    padding: 25px;
    width: 100%;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: var(--transition);
}

@media (min-width: 768px) {
    .shape-selector {
        max-width: 380px;
    }
}

.shape-selector h2 {
    color: white;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
    font-size: clamp(1.4rem, 2vw, 1.9rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.shapes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

@media (min-width: 576px) and (max-width: 767px) {
    .shapes-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 400px) {
    .shapes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.shape-option {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    transform: translateY(0);
}

.shape-option:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.shape-option.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--success);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-5px);
}

.shape-option i {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: white;
    margin-bottom: 12px;
    transition: var(--transition);
}

.shape-option span {
    color: white;
    font-weight: 500;
    font-size: clamp(0.9rem, 1.5vw, 1.15rem);
    transition: var(--transition);
    display: block;
}

.calculator {
    background: var(--card-bg);
    border-radius: 25px;
    padding: 30px;
    width: 100%;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .calculator {
        max-width: 650px;
        padding: 40px;
    }
}

.calculator-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.calculator-header h2 {
    color: var(--primary);
    font-size: clamp(1.5rem, 2.5vw, 2.4rem);
    margin-bottom: 8px;
    font-weight: 700;
}

.calculator-header p {
    color: var(--gray);
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    max-width: 500px;
    margin: 0 auto;
}

.shape-display {
    text-align: center;
    margin-bottom: 30px;
    min-height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.shape-svg {
    max-width: 180px;
    filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.12));
    transition: transform 0.5s ease;
}

@media (min-width: 768px) {
    .shape-svg {
        max-width: 200px;
    }
}

.shape-svg:hover {
    transform: scale(1.05);
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--dark);
    font-weight: 500;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 18px;
}

@media (min-width: 576px) {
    .input-row {
        flex-direction: row;
    }
}

.input-field {
    flex: 1;
    position: relative;
}

.input-field input {
    width: 100%;
    padding: 16px 20px;
    border-radius: 15px;
    border: 2px solid #e0e0e0;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    transition: var(--transition);
    background: rgba(245, 245, 245, 0.5);
    color: var(--dark);
    -webkit-appearance: none;
}

.input-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.2);
    outline: none;
}

.input-field input::placeholder {
    color: var(--gray);
    opacity: 0.7;
}

.unit-selector {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    cursor: pointer;
    padding: 5px;
}

.calculate-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 17px 30px;
    font-size: clamp(1.1rem, 1.3vw, 1.25rem);
    border-radius: 15px;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 7px 20px rgba(67, 97, 238, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.calculate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(67, 97, 238, 0.5);
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
}

.result-container {
    margin-top: 30px;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.08), rgba(114, 9, 183, 0.08));
    border-radius: 18px;
    padding: 25px;
    text-align: center;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(67, 97, 238, 0.15);
}

.result-container h3 {
    color: var(--primary);
    margin-bottom: 18px;
    font-size: clamp(1.2rem, 1.5vw, 1.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.result-value {
    font-size: clamp(2.2rem, 4vw, 3.5rem);
    font-weight: 800;
    color: var(--primary);
    margin: 15px 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.result-unit {
    color: var(--gray);
    font-size: clamp(1rem, 1.3vw, 1.25rem);
    font-weight: 500;
}

.history {
    margin-top: 30px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.history-header h3 {
    color: var(--primary);
    font-size: clamp(1.2rem, 1.4vw, 1.4rem);
    display: flex;
    align-items: center;
    gap: 10px;
}

.clear-history {
    background: rgba(247, 37, 133, 0.1);
    color: var(--accent);
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: clamp(0.85rem, 1vw, 1rem);
}

.clear-history:hover {
    background: rgba(247, 37, 133, 0.2);
}

.history-list {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 12px;
}

.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(245, 245, 245, 0.5);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(245, 245, 245, 0.5);
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: clamp(0.85rem, 1vw, 1rem);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.shape-tag {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 10px;
}

.footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255, 255, 255, 0.7);
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    padding-bottom: 15px;
}

.footer p a {
    color: #ffae00;
    font-weight: bold;
    text-decoration: none;
}

.footer p a:hover {
    color: aqua;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-container {
    animation: fadeIn 0.8s ease-out;
}

.shape-option {
    animation: fadeIn 0.5s ease-out;
    animation-fill-mode: backwards;
}

.shape-option:nth-child(1) {
    animation-delay: 0.1s;
}

.shape-option:nth-child(2) {
    animation-delay: 0.2s;
}

.shape-option:nth-child(3) {
    animation-delay: 0.3s;
}

.shape-option:nth-child(4) {
    animation-delay: 0.4s;
}

.shape-option:nth-child(5) {
    animation-delay: 0.5s;
}

.shape-option:nth-child(6) {
    animation-delay: 0.6s;
}

.shape-option:nth-child(7) {
    animation-delay: 0.7s;
}

.shape-option:nth-child(8) {
    animation-delay: 0.8s;
}

.seo-section {
    max-width: 960px;
    margin: 40px auto;
    padding: 30px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    line-height: 1.8;
    font-size: 1rem;
    color: var(--dark-color);
}

.seo-section h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.seo-section h3 {
    font-size: 1.4rem;
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--secondary-color);
}

.seo-section p {
    margin-bottom: 15px;
}

.seo-section ul {
    list-style: disc;
    padding-left: 20px;
    margin-bottom: 20px;
}

.seo-section ul li {
    margin-bottom: 10px;
}

.seo-section ol {
    list-style: decimal;
    padding-left: 20px;
    margin-bottom: 20px;
}

.seo-section ol li {
    margin-bottom: 10px;
}

.seo-section strong {
    color: var(--primary-color);
}

.seo-section a {
    color: var(--secondary-color);
    text-decoration: underline;
}

.seo-section a:hover {
    text-decoration: none;
}