/*
 * KEITO Storage Cloud - Material Design 3 Stylesheet
 * Integrates Android-like transitions, animations and component architectures.
 */

 :root {
    /* M3 Theme: Light */
    --md-sys-color-primary: #4355B9;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #DEE0FF;
    --md-sys-color-on-primary-container: #00105C;
    
    --md-sys-color-secondary: #5A5D72;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #DFE1F9;
    --md-sys-color-on-secondary-container: #171A2C;
    
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;
    
    --md-sys-color-background: #FEFBFF;
    --md-sys-color-on-background: #1B1B1F;
    --md-sys-color-surface: #FEFBFF;
    --md-sys-color-on-surface: #1B1B1F;
    --md-sys-color-surface-variant: #E3E1EC;
    --md-sys-color-on-surface-variant: #46464F;
    --md-sys-color-outline: #767680;
    --md-sys-color-surface-container: #F2EEF4;
    --md-sys-color-surface-container-high: #EBE7ED;
    --md-sys-color-surface-container-highest: #E5E1E8;

    /* Custom Success Colors mapped to M3 logic */
    --md-custom-success: #1E8E3E;
    --md-custom-success-container: #E6F4EA;
    --md-custom-on-success-container: #0D3C1A;

    /* Elevations */
    --md-sys-elevation-1: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15);

    /* Shapes */
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-full: 9999px;

    /* Transitions */
    --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0.0, 0.0, 1.0);
    --md-sys-motion-easing-standard: cubic-bezier(0.2, 0.0, 0.0, 1.0);
    --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0.0, 0.8, 0.15);
    --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1.0);
    --md-sys-motion-duration-short: 200ms;
    --md-sys-motion-duration-medium: 400ms;
    --md-sys-motion-duration-long: 600ms;
}

/* Dark Theme Support via Class */
.m3-theme-dark {
    --md-sys-color-primary: #BAC3FF;
    --md-sys-color-on-primary: #08218A;
    --md-sys-color-primary-container: #293CA0;
    --md-sys-color-on-primary-container: #DEE0FF;
    
    --md-sys-color-secondary: #C3C5DD;
    --md-sys-color-on-secondary: #2C2F42;
    --md-sys-color-secondary-container: #434659;
    --md-sys-color-on-secondary-container: #DFE1F9;
    
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-on-error-container: #FFDAD6;
    
    --md-sys-color-background: #1B1B1F;
    --md-sys-color-on-background: #E4E1E6;
    --md-sys-color-surface: #1B1B1F;
    --md-sys-color-on-surface: #E4E1E6;
    --md-sys-color-surface-variant: #46464F;
    --md-sys-color-on-surface-variant: #C6C5D0;
    --md-sys-color-outline: #90909A;
    
    --md-sys-color-surface-container: #202024;
    --md-sys-color-surface-container-high: #2A2A2E;
    --md-sys-color-surface-container-highest: #353439;

    --md-custom-success: #81C995;
    --md-custom-success-container: #133A20;
    --md-custom-on-success-container: #A8DDAE;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Material Symbols Adjustments */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Utilities */
.m3-mt-8 { margin-top: 8px; }
.m3-mt-16 { margin-top: 16px; }
.m3-color-primary { color: var(--md-sys-color-primary) !important; }
.m3-color-on-surface-variant { color: var(--md-sys-color-on-surface-variant) !important; }
.m3-color-error { color: var(--md-sys-color-error) !important; }

/* Typography */
.m3-typography-display-small { font-size: 36px; line-height: 44px; font-weight: 400; }
.m3-typography-headline-small { font-size: 24px; line-height: 32px; font-weight: 400; }
.m3-typography-title-large { font-size: 22px; line-height: 28px; font-weight: 400; }
.m3-typography-title-medium { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: 0.15px; }
.m3-typography-body-large { font-size: 16px; line-height: 24px; font-weight: 400; letter-spacing: 0.5px; }
.m3-typography-body-medium { font-size: 14px; line-height: 20px; font-weight: 400; letter-spacing: 0.25px; }
.m3-typography-label-large { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; }
.m3-typography-label-small { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.5px; }

/* Top App Bar */
.m3-top-app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    height: 64px;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background-color var(--md-sys-motion-duration-short) ease;
}

/* Icon Buttons */
.m3-icon-button {
    width: 48px;
    height: 48px;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.m3-icon-button:hover:not(:disabled) {
    background-color: rgba(var(--md-sys-color-on-surface), 0.08);
}

.m3-icon-button:disabled {
    opacity: 0.38;
    cursor: default;
}

.m3-icon-button-filled {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Layout */
.m3-main-container {
    padding: 24px;
    display: flex;
    justify-content: center;
    flex-grow: 1;
}

.m3-transition-container {
    width: 100%;
    max-width: 600px;
    position: relative;
}

/* Views (Shared Axis Configuration) */
.m3-view {
    position: absolute;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: 
        opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
        transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate),
        visibility var(--md-sys-motion-duration-medium);
}

.m3-view-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    position: relative;
    z-index: 1;
}

.m3-state-hidden {
    display: none;
}

/* Cards */
.m3-card {
    border-radius: var(--md-sys-shape-corner-extra-large);
    background-color: var(--md-sys-color-surface-container-highest);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.m3-card-elevated {
    background-color: var(--md-sys-color-surface-container);
    box-shadow: var(--md-sys-elevation-1);
}

.m3-card-filled {
    background-color: var(--md-sys-color-surface-container-highest);
    border: none;
}

.m3-card-header {
    padding: 24px 24px 0 24px;
}

.m3-card-subtitle {
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 8px;
}

.m3-card-content {
    padding: 24px;
}

.m3-center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
}

.m3-card-actions {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
}

/* Result Cards Specifics */
.m3-result-success .m3-result-icon {
    font-size: 40px;
    margin-bottom: 16px;
    color: var(--md-custom-success);
}

.m3-result-error .m3-result-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

/* Lists */
.m3-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.m3-list-item {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.m3-list-item:last-child {
    border-bottom: none;
}

.m3-list-item-overline {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
}

.m3-list-item-headline {
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
}


/* Content Elements: Upload Zone */
.m3-upload-zone {
    border: 2px dashed var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    background-color: transparent;
    transition: all var(--md-sys-motion-duration-short) ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.m3-upload-zone:hover, .m3-upload-zone.drag-over {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-variant);
}

.m3-upload-zone .m3-upload-icon {
    font-size: 48px;
    color: var(--md-sys-color-primary);
    margin-bottom: 16px;
}

.m3-file-input {
    display: none;
}

/* Upload Info Banner */
.m3-upload-info-surface {
    margin-top: 24px;
    padding: 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    background-color: var(--md-sys-color-surface-variant);
}

.m3-info-header, .m3-info-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.m3-progress-bar-container {
    height: 4px;
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: 2px;
    margin: 12px 0;
    overflow: hidden;
}

.m3-progress-bar-fill {
    height: 100%;
    background-color: var(--md-sys-color-primary);
    border-radius: 2px;
    transition: width var(--md-sys-motion-duration-long) var(--md-sys-motion-easing-emphasized);
}

/* FAB */
.m3-fab-container {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
}

.m3-fab {
    height: 56px;
    border-radius: 16px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    box-shadow: var(--md-sys-elevation-3);
    transition: box-shadow var(--md-sys-motion-duration-short) ease;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.m3-fab-primary {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.m3-fab:hover {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.4), 0 6px 16px 4px rgba(0, 0, 0, 0.2);
}

/* Buttons */
.m3-button {
    height: 40px;
    border-radius: 20px;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.m3-button-text {
    background: transparent;
    color: var(--md-sys-color-primary);
}

.m3-button-text:hover {
    background-color: rgba(var(--md-sys-color-primary), 0.08);
}

.m3-button-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.m3-button-error {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

/* Input Fields */
.m3-input-group {
    display: flex;
    gap: 8px;
}

.m3-text-field {
    flex: 1;
    height: 56px;
    background-color: var(--md-sys-color-surface-container-highest);
    border: none;
    border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
    border-radius: 4px 4px 0 0;
    padding: 8px 16px;
    color: var(--md-sys-color-on-surface);
    font-family: monospace;
    font-size: 16px;
    transition: border-bottom-color var(--md-sys-motion-duration-short) ease;
}

.m3-text-field:focus {
    outline: none;
    border-bottom: 2px solid var(--md-sys-color-primary);
    padding-bottom: 7px;
}

/* Circular Progress */
.m3-circular-progress {
    width: 48px;
    height: 48px;
    animation: rotate 2s linear infinite;
}

.m3-circular-progress-circle {
    stroke: var(--md-sys-color-primary);
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
    animation: dash 1.5s ease-in-out infinite;
    stroke-linecap: round;
}

@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 200; stroke-dashoffset: -35px; }
    100% { stroke-dasharray: 90, 200; stroke-dashoffset: -124px; }
}

/* Ripple Animation Setup */
.ripple-surface {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple-anim 600ms ease-out;
    background-color: currentColor;
    opacity: 0.12;
    pointer-events: none;
}

@keyframes ripple-anim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Snackbar */
.m3-snackbar {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
    padding: 14px 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 288px;
    max-width: 568px;
    box-shadow: var(--md-sys-elevation-2);
    transition: bottom var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
    z-index: 9999;
}

.m3-snackbar.show {
    bottom: 24px;
}

/* Responsive Overrides */
@media (max-width: 600px) {
    .m3-main-container { padding: 16px; }
    .m3-fab-label { display: none; }
    .m3-snackbar { width: calc(100% - 32px); }
}
