/* ========================================
   アルコールチェックシステム - カスタムCSS
   Material Design 3 スタイル
   ======================================== */

/* ----------------------------------------
   CSS Variables
   ---------------------------------------- */
:root {
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
}

/* ----------------------------------------
   Base Styles
   ---------------------------------------- */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

/* ----------------------------------------
   Safe Area Support
   ---------------------------------------- */
.safe-area-top {
    padding-top: var(--safe-area-inset-top);
}

.safe-area-bottom {
    padding-bottom: var(--safe-area-inset-bottom);
}

/* ----------------------------------------
   Animations
   ---------------------------------------- */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.animate-fade-in {
    animation: fade-in 0.5s ease-out forwards;
}

.animate-slide-up {
    animation: slide-up 0.5s ease-out forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

.animate-slide-down {
    animation: slide-down 0.3s ease-out forwards;
}

.animate-scale-in {
    animation: scale-in 0.3s ease-out forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* ----------------------------------------
   Form Elements
   ---------------------------------------- */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"] {
    font-size: 16px; /* Prevents zoom on iOS */
}

input:focus,
button:focus {
    outline: none;
}

/* Custom checkbox */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

input[type="checkbox"]:checked {
    background-color: #1976D2;
    border-color: #1976D2;
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ----------------------------------------
   Button Styles
   ---------------------------------------- */
button {
    cursor: pointer;
    user-select: none;
}

button:active {
    transform: scale(0.98);
}

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ----------------------------------------
   Navigation
   ---------------------------------------- */
.nav-item {
    position: relative;
    transition: all 0.2s ease;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 28px;
    background-color: #E3F2FD;
    border-radius: 14px;
    z-index: -1;
}

.nav-item:not(.active):hover {
    color: #64B5F6;
}

/* ----------------------------------------
   Cards
   ---------------------------------------- */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
}

/* ----------------------------------------
   Loading States
   ---------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ----------------------------------------
   Side Menu
   ---------------------------------------- */
#side-menu.open #menu-panel {
    transform: translateX(0);
}

#side-menu.open #menu-overlay {
    opacity: 1;
}

/* ----------------------------------------
   Status Badges
   ---------------------------------------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success {
    background-color: #E8F5E9;
    color: #2E7D32;
}

.status-badge.warning {
    background-color: #FFF3E0;
    color: #EF6C00;
}

.status-badge.error {
    background-color: #FFEBEE;
    color: #C62828;
}

.status-badge.info {
    background-color: #E3F2FD;
    color: #1565C0;
}

/* ----------------------------------------
   Scroll Behavior
   ---------------------------------------- */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ----------------------------------------
   Touch Feedback
   ---------------------------------------- */
.touch-feedback {
    transition: background-color 0.15s ease;
}

.touch-feedback:active {
    background-color: rgba(0, 0, 0, 0.05);
}

/* ----------------------------------------
   Modal / Dialog
   ---------------------------------------- */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ----------------------------------------
   Toast Notifications
   ---------------------------------------- */
#toast-container {
    position: fixed;
    bottom: calc(80px + var(--safe-area-inset-bottom));
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #323232;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: auto;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background-color: #2E7D32;
}

.toast.error {
    background-color: #C62828;
}

.toast.info {
    background-color: #1565C0;
}

/* ----------------------------------------
   Utilities
   ---------------------------------------- */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

/* ----------------------------------------
   Print Styles
   ---------------------------------------- */
@media print {
    .no-print {
        display: none !important;
    }
}

/* ----------------------------------------
   Reduced Motion
   ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ----------------------------------------
   Dark Mode Support (Future)
   ---------------------------------------- */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
}

/* ----------------------------------------
   Number Input Styles
   ---------------------------------------- */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ----------------------------------------
   Textarea Styles
   ---------------------------------------- */
textarea {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* ----------------------------------------
   Link Navigation Styles
   ---------------------------------------- */
a.nav-item {
    text-decoration: none;
}

/* ----------------------------------------
   Check Page Specific Styles
   ---------------------------------------- */
.judgment-pass {
    background-color: #E8F5E9;
    border-color: #A5D6A7;
}

.judgment-fail {
    background-color: #FFEBEE;
    border-color: #EF9A9A;
}

/* Vehicle history button hover effect */
#vehicle-history button:active {
    transform: scale(0.95);
}
