/* 반응형 레이아웃 최적화 */

/* 전체 화면 크기에 적용 - 다운로드 버튼 오른쪽 배치 */
.download-buttons-group {
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-end !important;
    align-items: center !important;
    width: 100% !important;
}

.card-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 15px !important;
}

.card-header > div {
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-end !important;
    align-items: center !important;
}

/* 모든 기기: 터치 친화적 UI */
@media (hover: none) and (pointer: coarse) {
    /* 터치 디바이스 최적화 */
    button,
    .btn,
    a {
        min-height: 44px; /* iOS 권장 터치 영역 */
        min-width: 44px;
    }
    
    /* 터치 피드백 */
    button:active,
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
    
    /* 스크롤 부드럽게 */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* 태블릿 (1024px 이하) */
@media (max-width: 1024px) {
    .container {
        padding: 20px;
    }
    
    .stats-cards {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .admin-menu {
        overflow-x: auto;
        white-space: nowrap;
        padding: 15px 10px;
    }
    
    .admin-menu-btn {
        display: inline-flex;
        min-width: 140px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
    }
    
    table {
        font-size: 13px;
    }
    
    table th,
    table td {
        padding: 10px 8px;
    }
}

/* 모바일 (768px 이하) */
@media (max-width: 768px) {
    /* 헤더 */
    .header {
        padding: 15px 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-content h1 {
        font-size: 20px;
        text-align: center;
    }
    
    .user-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .user-info span {
        font-size: 13px;
    }
    
    .user-info button {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    /* 컨테이너 */
    .container {
        padding: 15px 10px;
    }
    
    /* 통계 카드 */
    .stats-cards {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .card {
        padding: 20px 15px;
    }
    
    .card-header {
        display: flex !important;
        flex-direction: row !important;  /* column → row 변경 */
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
    }
    
    .card-header h2 {
        font-size: 18px;
        margin-bottom: 0;
        text-align: left;
        flex: 0 1 auto;
    }
    
    /* 내 연차 신청 내역 다운로드 버튼 그룹 - 오른쪽 배치 */
    .download-buttons-group {
        display: flex !important;
        gap: 8px !important;
        justify-content: flex-end !important;
        align-items: center !important;
        margin-left: auto !important;
        flex: 0 0 auto !important;
    }
    
    .card-header > div {
        display: flex !important;
        gap: 8px !important;
        justify-content: flex-end !important;
        align-items: center !important;
        width: 100% !important;
    }
    
    .card-header .btn {
        font-size: 13px;
        padding: 10px 12px;
        min-height: 44px;
        flex: 0 1 auto;
        white-space: nowrap;
    }
    
    .btn-success {
        justify-content: center;
    }
    
    /* 관리자 메뉴 */
    .admin-menu {
        padding: 10px 5px;
        gap: 5px;
    }
    
    .admin-menu-btn {
        min-width: 120px;
        font-size: 12px;
        padding: 10px 8px;
    }
    
    .admin-menu-btn i {
        display: none;
    }
    
    /* 테이블 */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 12px;
    }
    
    table th,
    table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* 내 연차 신청 내역 - 모바일 카드 형태 */
    #myRequestsTable {
        display: none; /* 모바일에서는 테이블 숨김 */
    }
    
    #myRequestsBody {
        display: block !important;
    }
    
    #myRequestsBody tr {
        display: block;
        background: white;
        border: 2px solid #e5e7eb;
        border-radius: 12px;
        padding: 20px;
        margin-bottom: 20px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    #myRequestsBody tr:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-color: #3b82f6;
    }
    
    #myRequestsBody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0;
        border: none;
        white-space: normal;
        text-align: left !important;
        margin-bottom: 12px;
        gap: 10px;
    }
    
    /* 신청일 - 헤더 역할 */
    #myRequestsBody td:nth-child(1) {
        font-size: 14px;
        color: #6b7280;
        padding-bottom: 10px;
        border-bottom: 2px solid #f3f4f6;
        margin-bottom: 15px;
    }
    
    #myRequestsBody td:nth-child(1)::before {
        content: "📅 신청일";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    /* 연차 타입 - 큰 뱃지 */
    #myRequestsBody td:nth-child(2) {
        margin-bottom: 15px;
    }
    
    #myRequestsBody td:nth-child(2)::before {
        content: "📋 타입";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    #myRequestsBody td:nth-child(2) .badge {
        font-size: 16px !important;
        padding: 10px 18px !important;
        border-radius: 8px !important;
        font-weight: bold !important;
        display: inline-block !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* 날짜 정보 */
    #myRequestsBody td:nth-child(3),
    #myRequestsBody td:nth-child(4),
    #myRequestsBody td:nth-child(5) {
        font-size: 16px;
        color: #1f2937;
        line-height: 1.6;
    }
    
    #myRequestsBody td:nth-child(3)::before {
        content: "📍 시작일";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        flex-shrink: 0;
        min-width: 80px;
    }
    
    #myRequestsBody td:nth-child(4)::before {
        content: "📍 종료일";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        flex-shrink: 0;
        min-width: 80px;
    }
    
    #myRequestsBody td:nth-child(5)::before {
        content: "⏱️ 일수";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        flex-shrink: 0;
        min-width: 80px;
    }
    
    #myRequestsBody td:nth-child(5) {
        font-size: 18px;
        font-weight: bold;
        color: #3b82f6;
    }
    
    /* 사유 - 세로 배치 유지 */
    #myRequestsBody td:nth-child(6) {
        background: #f9fafb;
        padding: 12px !important;
        border-radius: 8px;
        font-size: 14px;
        color: #4b5563;
        line-height: 1.5;
        display: block;
        margin-bottom: 15px;
    }
    
    #myRequestsBody td:nth-child(6)::before {
        content: "💬 사유";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        display: block;
        margin-bottom: 8px;
    }
    
    /* 상태 */
    #myRequestsBody td:nth-child(7) {
        margin-bottom: 15px;
    }
    
    #myRequestsBody td:nth-child(7)::before {
        content: "📊 상태";
        font-weight: bold;
        color: #374151;
        font-size: 14px;
        flex-shrink: 0;
        min-width: 80px;
    }
    
    #myRequestsBody td:nth-child(7) .status-badge {
        font-size: 16px !important;
        padding: 10px 18px !important;
        border-radius: 20px !important;
        font-weight: bold !important;
        display: inline-block !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* 관리 버튼 - 마지막 요소 */
    #myRequestsBody td:nth-child(8) {
        margin-bottom: 0;
        padding-top: 15px;
        border-top: 2px solid #f3f4f6;
        display: block;
    }
    
    #myRequestsBody td:nth-child(8)::before {
        display: none;
    }
    
    #myRequestsBody td:nth-child(8) .btn {
        width: auto !important;
        min-width: 160px !important;
        min-height: 50px !important;
        font-size: 16px !important;
        font-weight: bold !important;
        border-radius: 10px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
        transition: all 0.2s;
        float: left;
    }
    
    #myRequestsBody td:nth-child(8) .btn:active {
        transform: scale(0.98);
    }
    
    /* 취소 요청 버튼 - 빨간색 강조 */
    #myRequestsBody td:nth-child(8) .btn-danger {
        background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
        color: white !important;
        border: none !important;
    }
    
    #myRequestsBody td:nth-child(8) .btn-danger:hover {
        background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
        box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
    }
    
    /* 취소 요청 중 버튼 - 주황색 */
    #myRequestsBody td:nth-child(8) .btn-warning {
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
        color: white !important;
        border: none !important;
        font-size: 15px !important;
    }
    
    /* 취소 완료 버튼 - 회색 */
    #myRequestsBody td:nth-child(8) .btn-secondary {
        background: #9ca3af !important;
        color: white !important;
        border: none !important;
        font-size: 15px !important;
        cursor: not-allowed;
    }
    
    #myRequestsBody td:first-child {
        font-size: 14px;
        font-weight: bold;
        color: #1f2937;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
    
    #myRequestsBody td:first-child::before {
        content: '';
        display: none;
    }
    
    #myRequestsBody td:last-child {
        padding-top: 15px;
        border-top: 1px solid #e5e7eb;
        margin-top: 10px;
    }
    
    #myRequestsBody td:last-child::before {
        content: '';
        display: none;
    }
    
    /* 관리 버튼 */
    #myRequestsBody .btn-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    #myRequestsBody .btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
        font-size: 14px;
    }
    
    #myRequestsBody .btn i {
        margin-right: 5px;
    }
    
    /* 상태 배지 */
    #myRequestsBody .badge {
        display: inline-block;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 12px;
        font-weight: bold;
    }
    
    /* no-data */
    #myRequestsBody tr td.no-data {
        text-align: center;
        padding: 40px 20px;
        color: #9ca3af;
        font-size: 14px;
    }
    
    #myRequestsBody tr td.no-data::before {
        display: none;
    }
    
    /* 버튼 */
    .btn {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* 폼 */
    .form-row {
        gap: 12px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    /* 모달 */
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px 15px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    /* 검색/필터 */
    .search-filter-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-box,
    .filter-box {
        width: 100%;
    }
}

/* 소형 모바일 (480px 이하) */
@media (max-width: 480px) {
    /* 헤더 */
    .header-content h1 {
        font-size: 18px;
    }
    
    /* 직원 대시보드 통계 카드 최적화 */
    .stats-card {
        padding: 15px;
    }
    
    .stats-card h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .stats-card .stats-value {
        font-size: 24px;
        font-weight: bold;
    }
    
    .stats-card .stats-label {
        font-size: 12px;
        color: #6b7280;
    }
    
    /* 연차 신청 폼 최적화 */
    #leaveRequestForm {
        padding: 15px;
    }
    
    #leaveRequestForm .form-group {
        margin-bottom: 15px;
    }
    
    #leaveRequestForm label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }
    
    #leaveRequestForm input,
    #leaveRequestForm select,
    #leaveRequestForm textarea {
        font-size: 16px; /* iOS 확대 방지 */
        padding: 12px;
        width: 100%;
        border-radius: 8px;
    }
    
    #leaveRequestForm textarea {
        min-height: 100px;
    }
    
    /* 연차 신청 버튼 */
    #leaveRequestForm .btn-primary {
        width: 100%;
        font-size: 16px;
        padding: 14px;
        font-weight: 600;
    }
    
    /* 내 연차 신청 내역 테이블 */
    #myRequestsTable {
        font-size: 13px;
    }
    
    #myRequestsTable th,
    #myRequestsTable td {
        padding: 10px 8px;
    }
    
    /* 상태 뱃지 */
    .status-badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* 액션 버튼 */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .action-buttons .btn {
        width: 100%;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .header-content h1 i {
        display: none;
    }
    
    .user-info {
        width: 100%;
    }
    
    .user-info span {
        display: block;
        width: 100%;
        text-align: center;
        font-size: 12px;
    }
    
    .user-info button {
        flex: 1;
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .btn-icon span {
        display: none;
    }
    
    /* 컨테이너 */
    .container {
        padding: 10px 8px;
    }
    
    /* 카드 */
    .card {
        padding: 15px 10px;
        border-radius: 10px;
    }
    
    .card-header h2 {
        font-size: 16px;
    }
    
    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .card-content h3 {
        font-size: 13px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    /* 관리자 메뉴 */
    .admin-menu-btn {
        min-width: 100px;
        font-size: 11px;
        padding: 8px 6px;
    }
    
    /* 테이블 */
    table {
        font-size: 11px;
    }
    
    table th,
    table td {
        padding: 6px 4px;
    }
    
    /* 버튼 */
    .btn {
        font-size: 12px;
        padding: 7px 10px;
    }
    
    /* 폼 */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    /* 로그인 */
    .login-box {
        padding: 30px 20px;
    }
    
    .login-header h1 {
        font-size: 22px;
    }
    
    .login-header i {
        font-size: 50px;
    }
}

/* 가로 모드 최적화 (480px ~ 768px, 높이 480px 이하) */
@media (min-width: 480px) and (max-width: 768px) and (max-height: 480px) {
    .header {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .header-content h1 {
        font-size: 16px;
    }
    
    .container {
        padding: 10px;
    }
    
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .card {
        padding: 15px 10px;
    }
}

/* 대형 화면 (1440px 이상) */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
    
    .admin-menu {
        justify-content: center;
    }
    
    .modal-content {
        max-width: 800px;
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .admin-menu-btn,
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    input,
    select,
    textarea {
        min-height: 44px;
    }
    
    table td button {
        min-height: 36px;
        padding: 8px 12px;
    }
}

/* 인쇄 최적화 */
@media print {
    .header,
    .admin-menu,
    .btn,
    .modal,
    .notification {
        display: none !important;
    }
    
    .container {
        padding: 0;
    }
    
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    table {
        font-size: 10pt;
    }
    
    @page {
        margin: 1cm;
    }
}
