/**
 * Material Design 3 Theme for My Tools Social
 * Based on the existing violet theme (#712cf9)
 */

/* Import Roboto font */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    /* Primary color (violet from existing theme) */
    --md-sys-color-primary: #712cf9;
    --md-sys-color-primary-container: #e3d9ff;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-on-primary-container: #21005e;

    /* Secondary color */
    --md-sys-color-secondary: #6528e0;
    --md-sys-color-secondary-container: #e8ddff;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-on-secondary-container: #1d006c;

    /* Tertiary color */
    --md-sys-color-tertiary: #7d5260;
    --md-sys-color-tertiary-container: #ffd9e3;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-on-tertiary-container: #31101d;

    /* Surface colors */
    --md-sys-color-surface: #fef7ff;
    --md-sys-color-surface-variant: #e7e0ec;
    --md-sys-color-on-surface: #1d1b20;
    --md-sys-color-on-surface-variant: #49454f;

    /* Background */
    --md-sys-color-background: #fef7ff;
    --md-sys-color-on-background: #1d1b20;

    /* Error */
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-on-error-container: #410002;

    /* Outline */
    --md-sys-color-outline: #79747e;
    --md-sys-color-outline-variant: #c9c5d0;

    /* Shadow */
    --md-sys-color-shadow: #000000;
    --md-sys-color-scrim: #000000;

    /* Surface tints */
    --md-sys-color-surface-tint: #712cf9;

    /* Elevations */
    --md-sys-elevation-level0: 0px 0px 0px 0px rgba(0, 0, 0, 0);
    --md-sys-elevation-level1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-level4: 0px 6px 10px 4px rgba(0, 0, 0, 0.15), 0px 2px 3px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-level5: 0px 8px 12px 6px rgba(0, 0, 0, 0.15), 0px 4px 4px 0px rgba(0, 0, 0, 0.3);

    /* Typography scale */
    --md-sys-typescale-display-large-font: 'Roboto', sans-serif;
    --md-sys-typescale-display-large-size: 57px;
    --md-sys-typescale-display-large-weight: 400;
    --md-sys-typescale-display-large-line-height: 64px;

    --md-sys-typescale-headline-large-font: 'Roboto', sans-serif;
    --md-sys-typescale-headline-large-size: 32px;
    --md-sys-typescale-headline-large-weight: 400;
    --md-sys-typescale-headline-large-line-height: 40px;

    --md-sys-typescale-body-large-font: 'Roboto', sans-serif;
    --md-sys-typescale-body-large-size: 16px;
    --md-sys-typescale-body-large-weight: 400;
    --md-sys-typescale-body-large-line-height: 24px;

    /* Shape */
    --md-sys-shape-corner-none: 0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;
}

/* Dark theme */
[data-bs-theme="dark"] {
    --md-sys-color-primary: #cfbdff;
    --md-sys-color-primary-container: #5914d8;
    --md-sys-color-on-primary: #3a00a0;
    --md-sys-color-on-primary-container: #e9ddff;

    --md-sys-color-secondary: #cfc0ff;
    --md-sys-color-secondary-container: #4d0ccc;
    --md-sys-color-on-secondary: #340099;
    --md-sys-color-on-secondary-container: #e7deff;

    --md-sys-color-tertiary: #efb8c8;
    --md-sys-color-tertiary-container: #633b48;
    --md-sys-color-on-tertiary: #492532;
    --md-sys-color-on-tertiary-container: #ffd9e3;

    --md-sys-color-surface: #141218;
    --md-sys-color-surface-variant: #49454f;
    --md-sys-color-on-surface: #e6e1e9;
    --md-sys-color-on-surface-variant: #cac4cf;

    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #e6e1e9;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error: #690005;
    --md-sys-color-on-error-container: #ffdad6;

    --md-sys-color-outline: #948f99;
    --md-sys-color-outline-variant: #49454f;

    --md-sys-color-surface-tint: #cfbdff;
}

/* Base body styles */
body {
    font-family: var(--md-sys-typescale-body-large-font);
    font-size: var(--md-sys-typescale-body-large-size);
    line-height: var(--md-sys-typescale-body-large-line-height);
    color: var(--md-sys-color-on-background);
    background-color: var(--md-sys-color-background);
}

/* Material Design 3 Card */
.md-card,
.card {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    border: none;
    border-radius: 12px;
    box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    padding: 16px;
    margin-bottom: 16px;
    transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
    overflow: hidden;
}

.md-card:hover,
.card:hover {
    box-shadow: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
}

.md-card-elevated {
    box-shadow: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
}

.md-card-elevated:hover {
    box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
}

.md-card-filled {
    background-color: var(--md-sys-color-surface-variant);
}

/* Dark mode: add subtle border and shadows for better card visibility */
[data-bs-theme="dark"] .md-card,
[data-bs-theme="dark"] .md-card-elevated {
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0px 2px 6px 2px rgba(0, 0, 0, 0.3), 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .md-card-elevated:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.4), 0px 1px 3px 0px rgba(0, 0, 0, 0.6);
}

[data-bs-theme="dark"] .md-card-filled {
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.md-card-outlined {
    border: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: none;
}

/* Bootstrap Card components */
.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding: 16px 20px;
    margin: -16px -16px 16px -16px;
}

.card-body {
    padding: 0;
}

.card-body:first-child {
    padding: 0;
}

/* Material Design 3 Container */
.md-container {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    margin-bottom: 24px;
}

/* Material Design 3 Typography */
.md-headline-large {
    font: var(--md-sys-typescale-headline-large-weight) var(--md-sys-typescale-headline-large-size) / var(--md-sys-typescale-headline-large-line-height) var(--md-sys-typescale-headline-large-font);
    color: var(--md-sys-color-on-surface);
}

.md-headline-medium {
    font-size: 28px;
    font-weight: 400;
    line-height: 36px;
    color: var(--md-sys-color-on-surface);
}

.md-headline-small {
    font-size: 24px;
    font-weight: 400;
    line-height: 32px;
    color: var(--md-sys-color-on-surface);
}

.md-body-large {
    font: var(--md-sys-typescale-body-large-weight) var(--md-sys-typescale-body-large-size) / var(--md-sys-typescale-body-large-line-height) var(--md-sys-typescale-body-large-font);
    color: var(--md-sys-color-on-surface);
}

.md-body-medium {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--md-sys-color-on-surface);
}

.md-label-large {
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: 0.1px;
    color: var(--md-sys-color-on-surface);
}

/* Material Design 3 Divider */
.md-divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    border: none;
    margin: 16px 0;
}

/* Material Design 3 Surface */
.md-surface {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
}

.md-surface-variant {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
}

/* Material Design 3 Spacing */
.md-spacing-small {
    padding: 8px;
}

.md-spacing-medium {
    padding: 16px;
}

.md-spacing-large {
    padding: 24px;
}

/* Smooth transitions */
* {
    transition-property: background-color, color, border-color, box-shadow;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

/* Material Design 3 Buttons */
md-filled-button,
.md-filled-button,
button[type="submit"],
input[type="submit"],
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 32px;
    border-radius: 24px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 300px;
    margin: 24px auto;
}

md-filled-button:hover,
.md-filled-button:hover,
button[type="submit"]:hover,
input[type="submit"]:hover,
.btn-primary:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 92%, var(--md-sys-color-on-primary) 8%);
    box-shadow: 0 1px 2px 0 color-mix(in srgb, var(--md-sys-color-shadow) 30%, transparent),
                0 2px 6px 2px color-mix(in srgb, var(--md-sys-color-shadow) 15%, transparent);
    transform: translateY(-2px);
}

md-filled-button:active,
.md-filled-button:active,
button[type="submit"]:active,
input[type="submit"]:active,
.btn-primary:active {
    transform: scale(0.98);
}

/* Ripple effect */
button[type="submit"]::before,
input[type="submit"]::before,
.md-filled-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--md-sys-color-on-primary) 30%, transparent);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button[type="submit"]:active::before,
input[type="submit"]:active::before,
.md-filled-button:active::before {
    width: 300px;
    height: 300px;
}

/* Material Design 3 Chips */
md-chip-set {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

md-assist-chip, .md-assist-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 16px;
    border-radius: 8px;
    background-color: transparent;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

md-assist-chip:hover, .md-assist-chip:hover {
    background-color: var(--md-sys-color-surface-variant);
}

md-assist-chip svg, .md-assist-chip svg {
    width: 18px;
    height: 18px;
}

/* Material Design 3 Text Field */
.md-text-field {
    position: relative;
    width: 100%;
}

.md-text-field input,
input[type="text"],
input[type="url"],
textarea {
    width: 100%;
    height: 56px;
    padding: 16px 20px;
    border-radius: 28px;
    border: 2px solid var(--md-sys-color-outline);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    box-sizing: border-box;
}

.md-text-field input:focus,
input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus {
    outline: none;
    border: 2px solid var(--md-sys-color-primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
}

.md-text-field input::placeholder,
input[type="text"]::placeholder,
input[type="url"]::placeholder,
textarea::placeholder {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.7;
}

/* Override Bootstrap with Material colors for compatibility during migration */
.bg-body-tertiary {
    background-color: var(--md-sys-color-surface-variant) !important;
}

.alert-danger {
    background-color: var(--md-sys-color-error-container) !important;
    color: var(--md-sys-color-on-error-container) !important;
    border-color: var(--md-sys-color-error) !important;
}

.alert-secondary {
    background-color: var(--md-sys-color-secondary-container) !important;
    color: var(--md-sys-color-on-secondary-container) !important;
}

/* Material Design 3 Top App Bar / Navigation */
.md-top-app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
}

.md-navigation {
    width: 100%;
}

.md-nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.md-nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
    font-size: 20px;
    font-family: 'Roboto', sans-serif;
}

.md-nav-brand img {
    border-radius: 8px;
}

.md-nav-title {
    display: none;
}

@media (min-width: 768px) {
    .md-nav-title {
        display: inline;
    }
}

.md-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: none;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    transition: background-color 0.2s;
}

.md-nav-toggle:hover {
    background-color: var(--md-sys-color-surface-variant);
}

@media (min-width: 768px) {
    .md-nav-toggle {
        display: none;
    }
}

.md-nav-menu {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background-color: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    padding: 16px;
}

.md-nav-menu-open {
    display: block;
}

@media (min-width: 768px) {
    .md-nav-menu {
        display: flex;
        position: static;
        background-color: transparent;
        border-bottom: none;
        box-shadow: none;
        padding: 0;
        flex: 1;
        align-items: center;
        justify-content: space-between;
    }
}

.md-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (min-width: 768px) {
    .md-nav-list {
        flex-direction: row;
        gap: 4px;
    }
}

.md-nav-item {
    margin: 0;
}

.md-nav-link {
    display: block;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.md-nav-link:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.md-nav-item-active .md-nav-link {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.md-nav-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

@media (min-width: 768px) {
    .md-nav-actions {
        flex-direction: row;
        align-items: center;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
}

.md-icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: none;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.md-icon-button:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.md-nav-lang-text {
    font-family: 'Roboto', sans-serif;
    font-size: 12px;
    font-weight: 500;
    position: absolute;
    bottom: 2px;
    right: 2px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
}

.md-nav-language {
    position: relative;
}

.md-menu {
    display: none;
    position: absolute;
    top: 48px;
    right: 0;
    min-width: 120px;
    max-height: 320px;
    background-color: var(--md-sys-color-surface);
    border-radius: 4px;
    box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
    padding: 8px 0;
    z-index: 1001;
    overflow-y: auto;
}

.md-menu::-webkit-scrollbar {
    width: 8px;
}

.md-menu::-webkit-scrollbar-track {
    background: transparent;
}

.md-menu::-webkit-scrollbar-thumb {
    background-color: var(--md-sys-color-outline-variant);
    border-radius: 4px;
    transition: background-color 0.2s;
}

.md-menu::-webkit-scrollbar-thumb:hover {
    background-color: var(--md-sys-color-outline);
}

/* Firefox scrollbar */
.md-menu {
    scrollbar-width: thin;
    scrollbar-color: var(--md-sys-color-outline-variant) transparent;
}

.md-menu-open {
    display: block;
}

.md-menu-item {
    display: block;
    padding: 12px 16px;
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    transition: background-color 0.2s;
}

.md-menu-item:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.theme-icon-dark {
    display: none;
}

.md-outlined-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    border-radius: 20px;
    background-color: transparent;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-primary);
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.md-outlined-button:hover {
    background-color: var(--md-sys-color-surface-variant);
}

@media (max-width: 767px) {
    .md-share-button {
        width: 100%;
    }
}

/* Adjust body padding for fixed header */
body {
    padding-top: 80px;
}

/* CSS Grid System (Bootstrap replacement) */
.container {
    width: 100%;
    padding-right: 16px;
    padding-left: 16px;
    margin-right: auto;
    margin-left: auto;
    padding-top: 24px;
    padding-bottom: 24px;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -8px;
    margin-left: -8px;
}

.col, [class*="col-"] {
    padding-right: 8px;
    padding-left: 8px;
}

.col-md-3 {
    flex: 0 0 auto;
    width: 100%;
}

.col-md-4 {
    flex: 0 0 auto;
    width: 100%;
}

.col-md-6 {
    flex: 0 0 auto;
    width: 100%;
}

.col-md-8 {
    flex: 0 0 auto;
    width: 100%;
}

.col-md-9 {
    flex: 0 0 auto;
    width: 100%;
}

.col-md-12 {
    flex: 0 0 auto;
    width: 100%;
}

@media (min-width: 768px) {
    .col-md-3 {
        width: 25%;
    }

    .col-md-4 {
        width: 33.333333%;
    }

    .col-md-6 {
        width: 50%;
    }

    .col-md-8 {
        width: 66.666667%;
    }

    .col-md-9 {
        width: 75%;
    }

    .col-md-12 {
        width: 100%;
    }

    .offset-md-3 {
        margin-left: 25%;
    }
}

.justify-content-md-center {
    justify-content: center;
}

.text-center {
    text-align: center;
}

.text-start {
    text-align: start;
}

.overflow-y-scroll {
    overflow-y: scroll;
}

/* Improve container spacing */
.md-container {
    margin-bottom: 32px;
}
