/* TTC Mobile Optimization */

/* Mobile Touch Target Sizing */
@media (max-width: 768px) {
    button,
    a[role="button"],
    input[type="button"],
    input[type="submit"],
    .ttc-btn {
        min-height: 44px;
        min-width: 44px;
        padding: var(--ttc-space-md) var(--ttc-space-lg);
    }
    
    input,
    select,
    textarea {
        min-height: 44px;
        padding: var(--ttc-space-md) var(--ttc-space-md);
        font-size: 16px;
    }
    
    /* Prevent iOS zoom on input focus */
    input,
    select,
    textarea {
        font-size: 16px;
    }
}

/* Mobile Viewport */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        padding: 0;
        margin: 0;
    }
    
    main {
        padding: var(--ttc-space-lg);
    }
}

/* Mobile Navigation */
.ttc-mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--ttc-bg-card);
    border-top: 1px solid var(--ttc-border-light);
    padding: var(--ttc-space-md) 0;
    z-index: 100;
}

@media (max-width: 768px) {
    .ttc-mobile-nav {
        display: flex;
        justify-content: space-around;
        padding-bottom: var(--ttc-space-md);
    }
}

.ttc-mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--ttc-space-xs);
    padding: var(--ttc-space-sm) var(--ttc-space-md);
    text-decoration: none;
    color: var(--ttc-text-muted);
    font-size: var(--ttc-fs-xs);
    transition: color var(--ttc-transition-fast);
}

.ttc-mobile-nav-item.active {
    color: var(--ttc-primary);
}

.ttc-mobile-nav-item:active {
    background: rgba(99, 102, 241, 0.1);
}

/* Hamburger Menu */
.ttc-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    padding: var(--ttc-space-md);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

@media (max-width: 768px) {
    .ttc-hamburger {
        display: flex;
    }
}

.ttc-hamburger span {
    width: 24px;
    height: 2px;
    background: var(--ttc-text-main);
    border-radius: 1px;
    transition: all var(--ttc-transition-fast);
}

.ttc-hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.ttc-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.ttc-hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile Drawer/Sidebar */
.ttc-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: var(--ttc-bg-card);
    box-shadow: var(--ttc-shadow-lg);
    z-index: 99;
    transition: left var(--ttc-transition-standard);
    overflow-y: auto;
}

.ttc-drawer.open {
    left: 0;
}

@media (max-width: 768px) {
    .ttc-drawer {
        width: 75vw;
        max-width: 280px;
    }
}

.ttc-drawer-header {
    padding: var(--ttc-space-lg);
    border-bottom: 1px solid var(--ttc-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ttc-drawer-close {
    background: transparent;
    border: none;
    font-size: var(--ttc-fs-lg);
    cursor: pointer;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ttc-drawer-content {
    padding: var(--ttc-space-lg);
}

.ttc-drawer-item {
    display: block;
    padding: var(--ttc-space-md) 0;
    color: var(--ttc-text-main);
    text-decoration: none;
    transition: color var(--ttc-transition-fast);
    border-bottom: 1px solid var(--ttc-border-light);
}

.ttc-drawer-item:hover {
    color: var(--ttc-primary);
}

.ttc-drawer-item.active {
    color: var(--ttc-primary);
    font-weight: var(--ttc-fw-semibold);
}

/* Drawer Overlay */
.ttc-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 98;
    transition: background var(--ttc-transition-fast);
    display: none;
}

.ttc-drawer-overlay.open {
    background: rgba(0, 0, 0, 0.5);
    display: block;
}

/* Bottom Sheet */
.ttc-bottom-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: var(--ttc-bg-card);
    border-radius: var(--ttc-radius-xl) var(--ttc-radius-xl) 0 0;
    z-index: 100;
    transition: bottom var(--ttc-transition-standard);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--ttc-shadow-lg);
}

.ttc-bottom-sheet.open {
    bottom: 0;
}

.ttc-bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--ttc-border-light);
    border-radius: 2px;
    margin: var(--ttc-space-md) auto;
}

.ttc-bottom-sheet-header {
    padding: var(--ttc-space-lg);
    border-bottom: 1px solid var(--ttc-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ttc-bottom-sheet-title {
    font-size: var(--ttc-fs-lg);
    font-weight: var(--ttc-fw-semibold);
}

.ttc-bottom-sheet-close {
    background: transparent;
    border: none;
    font-size: var(--ttc-fs-lg);
    cursor: pointer;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
}

.ttc-bottom-sheet-content {
    padding: var(--ttc-space-lg);
}

/* Responsive Grid */
@media (max-width: 768px) {
    .ttc-grid-2 {
        grid-template-columns: 1fr;
    }
    
    .ttc-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ttc-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .ttc-grid-3 {
        grid-template-columns: 1fr;
    }
    
    .ttc-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Mobile Modal */
.ttc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 101;
}

.ttc-modal.open {
    display: flex;
}

@media (max-width: 768px) {
    .ttc-modal-content {
        margin: var(--ttc-space-lg);
        max-height: 90vh;
        overflow-y: auto;
        width: 100%;
    }
}

/* Mobile Swipe Actions */
.ttc-swipe-item {
    position: relative;
    overflow: hidden;
}

.ttc-swipe-actions {
    position: absolute;
    top: 0;
    right: -100px;
    height: 100%;
    display: flex;
    transition: right var(--ttc-transition-fast);
}

.ttc-swipe-item.swiped .ttc-swipe-actions {
    right: 0;
}

.ttc-swipe-action {
    padding: var(--ttc-space-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    font-weight: var(--ttc-fw-semibold);
    color: white;
}

.ttc-swipe-action.delete {
    background: #ef4444;
}

.ttc-swipe-action.edit {
    background: var(--ttc-primary);
}

/* Sticky Header on Mobile */
@media (max-width: 768px) {
    .ttc-sticky-header {
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--ttc-bg-card);
        border-bottom: 1px solid var(--ttc-border-light);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Mobile Optimized Forms */
@media (max-width: 768px) {
    .ttc-form-row {
        display: flex;
        flex-direction: column;
        gap: var(--ttc-space-md);
    }
    
    .ttc-form-row > * {
        flex: 1;
    }
}

/* Safe Area Support (notch/punch-hole) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* Responsive Typography */
@media (max-width: 768px) {
    h1 {
        font-size: var(--ttc-fs-2xl);
    }
    
    h2 {
        font-size: var(--ttc-fs-xl);
    }
    
    h3 {
        font-size: var(--ttc-fs-lg);
    }
}

/* Touch Feedback */
@media (pointer: coarse) {
    button:active,
    a:active,
    .ttc-btn:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Prevent Double-Tap Zoom */
@media (max-width: 768px) {
    button,
    a {
        touch-action: manipulation;
    }
}
