/* Base Styles */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
    border: none;
    box-sizing: border-box;
}

:root {
    --primary-color: #e0e5ec;
    --secondary-color: #d1d9e6;
    --text-color: #4a4a4a;
    --shadow-color: #a3b1c6;
    --highlight-color: #ffffff;
    --accent-color: #5e72e4;
    --transition-duration: 0.2s;
    --outer-shadow: 4px 4px 8px var(--shadow-color), -4px -4px 8px var(--highlight-color);
    --outer-shadow-small: 2px 2px 4px var(--shadow-color), -2px -2px 4px var(--highlight-color);
    --inner-shadow: inset 2px 2px 5px var(--shadow-color), inset -2px -2px 5px var(--highlight-color);
    --inner-shadow-deep: inset 4px 4px 8px var(--shadow-color), inset -4px -4px 8px var(--highlight-color);
    --text-shadow: 0.5px 0.5px 2px #00000088;
    --header-height: 60px; /* Define header height for spacing */
}

/* Global Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-color);
    background-color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Text Shadows */
body,
.app-header h1,
.tool-icon,
.tool-name,
.option-button,
.action-button,
.back-button,
.result-display,
.text-input,
.toast,
.slider-label,
.options-label,
.input-label {
    text-shadow: var(--text-shadow);
}

/* Common Element Styles */
.back-button,
.option-button,
.action-button,
.result-display,
.tool-card {
    background-color: var(--primary-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-duration);
}

/* Outer Shadow Elements */
.app-header,
.tool-content,
.tool-card,
.option-button,
.action-button,
.result-display,
.toast,
#totpDisplay {
    box-shadow: var(--outer-shadow);
}

/* Inner Shadow Elements */
.slider,
.options-group,
.totp-display-container,
.qr-display {
    box-shadow: var(--inner-shadow);
}

/* Interactive States */
.option-button:active,
.option-button.active,
.action-button:active,
.back-button:active,
.result-display:active,
#generateUuidButton:active,
#totpDisplay:active {
    box-shadow: var(--inner-shadow);
    transform: translateY(2px);
}

.option-button:hover,
.action-button:hover,
.result-display:hover,
.tool-card:hover,
#totpDisplay:hover {
    box-shadow: var(--outer-shadow-small);
}

.option-button:active:hover,
.option-button.active:hover {
    box-shadow: var(--inner-shadow-deep);
}

.result-display:active,
#totpDisplay:active {
    box-shadow: var(--inner-shadow-deep);
}

/* Text Inputs & Base Inputs */
.text-input,
.base64-input,
.base-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 15px;
    background-color: var(--primary-color);
    margin-bottom: 20px;
    transition: all var(--transition-duration);
    outline: none;
    box-shadow: none;
}

.text-input:hover,
.base64-input:hover,
.base-input:hover {
    box-shadow: var(--inner-shadow);
}

.text-input:focus,
.base-input:focus,
.base64-input:focus,
.base-input:focus {
    box-shadow: var(--inner-shadow-deep);
}

/* Special Input Styles */
.base64-input {
    min-height: 180px;
    resize: none;
    margin-bottom: 0px;
}

.base-input,
.base64-input {
    font-family: Consolas, 'Courier New', monospace;
}

.tool-card:hover {
    transform: translateY(3px);
}

.qr-display:hover,
.qr-display:active {
    box-shadow: var(--inner-shadow);
    transform: none;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--primary-color);
    position: relative;
    overflow-x: hidden; /* Prevent horizontal scrolling during transitions */
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    padding: 16px;
    z-index: 10;
    margin-bottom: 20px; /* Increased margin bottom */
    height: var(--header-height);
    position: relative; /* Position relative for proper z-index */
}

.back-button {
    display: none;
    height: 30px;
    width: 30px;
    border-radius: 50%;
    margin-right: 15px;
    box-shadow: var(--outer-shadow-small);
}

.app-header h1,
#homePage {
    margin: 0;
    font-weight: 600;
    font-size: 24px;
}

/* Pages - Updated for slide transitions */
.page {
    display: none;
    width: 100%;
    padding: 20px;
    position: absolute;
    left: 0;
    right: 0;
    top: var(--header-height); /* Position pages properly below header */
    transition: transform 0.3s cubic-bezier(.25,.1,0,1), opacity 0.3s ease;
    transform: translateX(0);
    opacity: 1;
    min-height: calc(100vh - var(--header-height)); /* Ensure pages fill viewport height */
}

.page.active {
    display: block;
}

/* Sliding animations */
.page.slide-out-left {
    transform: translateX(-100%);
    opacity: 0;
}

.page.slide-out-right {
    transform: translateX(100%);
    opacity: 0;
}

.page.slide-in-left {
    transform: translateX(-100%);
    opacity: 0;
}

.page.slide-in-right {
    transform: translateX(100%);
    opacity: 0;
}

/* Animation trigger classes */
.page.animate-in {
    transform: translateX(0);
    opacity: 1;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 30px;
    padding: 16px;
    padding-top: 30px; /* Added extra padding at top */
}

.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    aspect-ratio: 1/1;
    border-radius: 20px;
}

.tool-icon {
    font-size: 36px;
    margin-bottom: 15px;
    color: var(--text-color);
}

.tool-name {
    font-weight: 600;
    font-size: 16px;
}

/* Tool Content */
.tool-content {
    max-width: 600px;
    margin: 10% auto auto;
    padding: 15px;
    border-radius: 15px;
    background-color: var(--primary-color);
    transform: scale(1.1);
}

/* Labels */
.slider-label,
.options-label,
.input-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

/* Slider */
.slider-container,
.options-container {
    margin-bottom: 20px;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--primary-color);
    outline: none;
    border-radius: 3px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: var(--outer-shadow);
}

/* Options */
.options-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    border-radius: 15px;
}

.option-button {
    flex: 1;
    min-width: 70px;
    padding: 10px;
    text-align: center;
}

/* Result Display */
.result-display {
    padding: 15px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-radius: 15px;
    margin-bottom: 20px;
    color: var(--text-color);
}

#passwordDisplay,
#uuidDisplay,
#qrDisplay {
    margin-bottom: 0;
}

#generateUuidButton {
    margin-top: 20px;
}

/* QR Code */
.qr-display {
    min-height: 290px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* TOTP */
.totp-display-container {
    position: relative;
    padding: 15px;
    border-radius: 15px;
    overflow: hidden;
}

#totpDisplay {
    padding: 8px;
    font-size: 40px;
    position: relative;
    z-index: 2;
    border-radius: 10px;
    margin-bottom: 0;
}

.timer-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #4A4A4A;
    opacity: 0.2;
    z-index: 1;
    transition: width 1s cubic-bezier(.2, .3, .3, 1);
    pointer-events: none;
    box-shadow: var(--inner-shadow-deep);
}

/* Action Button */
.action-button {
    display: block;
    width: 100%;
    padding: 15px;
    border-radius: 15px;
    color: var(--text-color);
    font-weight: 600;
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    padding: 12px 24px;
    border-radius: 15px;
    opacity: 0;
    transition: opacity var(--transition-duration);
}

.toast.show {
    opacity: 1;
}

/* Monospace Text */
#passwordDisplay,
#uuidDisplay,
#totpDisplay {
    font-family: Consolas, 'Courier New', monospace;
    letter-spacing: 0.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: var(--text-shadow);
}

#passwordDisplay,
#uuidDisplay {
    font-size: 20px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tool-content {
        transform: scale(1);
    }
}

@media (max-width: 480px) {
    .options-group {
        flex-direction: column;
    }

    .option-button {
        width: 100%;
    }

    #totpDisplay {
        font-size: 32px;
    }
}