body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
}

header {
    background-color: #333;
    color: #fff;
    padding: 10px 20px;
    position: fixed; /* 상단에 고정 */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; /* 다른 요소들 위에 오도록 */
    box-sizing: border-box;
}

nav {
    display: flex;
    justify-content: space-between; /* 로고와 로그인 버튼을 양쪽 끝으로 */
    align-items: center;
    max-width: 1200px; /* 콘텐츠 최대 너비 설정 */
    margin: 0 auto; /* 가운데 정렬 */
}

nav .logo a {
    color: #fff;
    text-decoration: none;
    font-size: 1.5em;
    font-weight: bold;
}

nav .auth-links a,
nav .auth-links button { /* 버튼도 a 태그와 유사하게 스타일링 */
    color: #fff;
    text-decoration: none;
    padding: 8px 15px;
    border: 1px solid #fff;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
    background-color: transparent; /* 버튼 배경 투명하게 */
    cursor: pointer;
    font-size: 1em; /* a 태그와 폰트 크기 일치 */
    margin-left: 10px; /* 로그인 버튼과의 간격 */
}

nav .auth-links a:hover,
nav .auth-links button:hover {
    background-color: #fff;
    color: #333;
}

main {
    padding: 90px 20px 20px; /* 헤더 높이 고려하여 패딩 조정 */
    max-width: 1200px;
    margin: 0 auto; /* 가운데 정렬 */
}

.main-title-bar {
    display: flex;
    justify-content: space-between; /* 양쪽 끝으로 정렬 */
    align-items: center; /* 수직 중앙 정렬 */
    margin-bottom: 20px; /* 테이블과의 간격 */
}

.main-title-bar h1 {
    margin: 0; /* h1 기본 마진 제거 */
}

/* Add 버튼에 대한 기존 스타일이 nav .auth-links button 에 있었다면,
   별도의 스타일을 지정하거나, 기존 스타일을 일반화해야 할 수 있습니다.
   여기서는 #add-link-btn 에 직접 스타일을 적용합니다. */
#add-link-btn {
    padding: 8px 15px;
    border: 1px solid #007bff; /* 테두리 색상 변경 또는 유지 */
    border-radius: 5px;
    background-color: #007bff; /* 배경색 변경 또는 유지 */
    color: white; /* 글자색 변경 또는 유지 */
    cursor: pointer;
    font-size: 1em;
    /* margin-left는 더 이상 필요 없을 수 있음 */
}

#add-link-btn:hover {
    background-color: #0056b3;
    /* color: #333; */ /* 필요시 호버 색상 조정 */
}

#link-list-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto; /* 내용이 길 경우 가로 스크롤 */
}

#link-list-container table {
    width: 100%;
    border-collapse: collapse; /* 테이블 셀 사이의 간격 제거 */
    margin-top: 20px;
}

#link-list-container th,
#link-list-container td {
    border: 1px solid #ddd; /* 셀 테두리 */
    padding: 12px; /* 셀 안쪽 여백 */
    text-align: left; /* 텍스트 왼쪽 정렬 */
    vertical-align: top; /* 내용이 길 경우 위쪽 정렬 */
}

#link-list-container th {
    background-color: #f8f8f8; /* 헤더 배경색 */
    font-weight: bold;
}

#link-list-container td a {
    color: #007bff;
    text-decoration: none;
}

#link-list-container td a:hover {
    text-decoration: underline;
}

/* --- 아이콘 버튼 스타일 (모든 뷰에 적용) --- */
#link-list-container .edit-btn,
#link-list-container .delete-btn,
#link-list-container .order-up-btn,
#link-list-container .order-down-btn {
    font-size: 1.2em; /* 아이콘 크기 조절 */
    padding: 8px;     /* 아이콘 주변 여백 */
    margin: 0 0 0 8px; /* 버튼 간 간격 (모바일과 동일하게 유지 또는 조정) */
    background-color: transparent;
    border: none;
    color: #555; /* 아이콘 색상 */
    text-indent: -9999px; /* 텍스트 숨김 */
    overflow: hidden;
    width: 30px;  /* 버튼 너비 */
    height: 30px; /* 버튼 높이 */
    display: inline-flex; /* 아이콘 중앙 정렬을 위해 */
    align-items: center;
    justify-content: center;
    position: relative; /* ::before 가상 요소의 위치 기준 */
    cursor: pointer;
}

#link-list-container .edit-btn:hover,
#link-list-container .delete-btn:hover,
#link-list-container .order-up-btn:hover,
#link-list-container .order-down-btn:hover {
    background-color: #e0e0e0; /* 호버 시 배경색 (선택 사항) */
    /* color: #333; */ /* 호버 시 아이콘 색상 변경 (선택 사항) */
}

#link-list-container .edit-btn::before,
#link-list-container .delete-btn::before,
#link-list-container .order-up-btn::before,
#link-list-container .order-down-btn::before {
    text-indent: 0; /* 숨겨진 텍스트 다시 표시 (아이콘이므로) */
    position: absolute;
    /* 아이콘이 버튼 중앙에 오도록 미세 조정이 필요할 수 있음 */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#link-list-container .edit-btn::before { content: "✏️"; }
#link-list-container .delete-btn::before { content: "🗑️"; }
#link-list-container .order-up-btn::before { content: "🔼"; }
#link-list-container .order-down-btn::before { content: "🔽"; }
/* --- 아이콘 버튼 스타일 끝 --- */

#link-list-container button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 기본 버튼 스타일 (선택 사항) */
button, #login-google-btn {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

button:hover, #login-google-btn:hover {
    background-color: #0056b3;
}

button#login-google-btn { /* ID를 명시하여 기존 스타일과 충돌 방지 */
    /* 기존 스타일 유지 또는 필요시 조정 */
}

/* 로그인 페이지의 버튼과 상태 메시지 스타일 (선택 사항) */
#google-login-btn { /* login.html의 버튼 ID와 동일하게 */
    display: block;
    margin: 20px auto;
}

#login-status {
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
}

/* Modal Styles */
.modal {
    position: fixed; /* 화면에 고정 */
    z-index: 1001; /* 다른 요소들 위에 표시 (헤더보다 높게) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* 내용이 길면 스크롤 */
    background-color: rgba(0,0,0,0.4); /* 반투명 배경 */
    display: flex; /* 모달 내용을 중앙 정렬하기 위해 */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto; /* 자동 마진으로 중앙 정렬 (flex 사용 시 불필요할 수 있음) */
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px; /* 모달 최대 너비 */
    border-radius: 8px;
    position: relative;
}

.close-btn {
    color: #aaa;
    float: right; /* 우측 상단으로 이동 */
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#add-link-form div {
    margin-bottom: 15px;
}

#add-link-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#add-link-form input[type="text"],
#add-link-form input[type="url"],
#add-link-form textarea {
    width: calc(100% - 22px); /* 패딩, 보더 고려 */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#add-link-form textarea {
    resize: vertical;
    min-height: 80px;
}

#add-link-form button[type="submit"] {
    background-color: #28a745; /* Green */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

#add-link-form button[type="submit"]:hover {
    background-color: #218838;
}

/* 모바일 반응형 스타일 */
@media (max-width: 768px) {
    #link-list-container table thead {
        display: none;
    }

    #link-list-container table,
    #link-list-container table tbody,
    #link-list-container table tr,
    #link-list-container table td {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
    }

    #link-list-container table tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        padding: 10px;
        position: relative; /* 액션 버튼의 상대 위치 기준 (로그인 시에만 유효) */
    }

    #link-list-container table td {
        border: none;
        padding: 8px 0;
        text-align: left !important;
        /* display: block; 기본값으로 설정하고 필요한 경우 아래에서 flex 등으로 변경 */
        margin-bottom: 5px;
    }

    #link-list-container table td[data-label]::before {
        content: attr(data-label);
        font-weight: bold;
        display: inline-block;
        min-width: 70px;
        margin-right: 10px;
        vertical-align: top;
    }

    /* 번호, 이름, 링크는 한 줄에 표시 */
    #link-list-container table td:nth-child(1), /* 번호 */
    #link-list-container table td:nth-child(2), /* 이름 */
    #link-list-container table td:nth-child(3)  /* 링크 */
    {
        display: flex;
        align-items: flex-start;
    }

    #link-list-container table td:nth-child(3) a { /* 링크 */
        word-break: break-all;
        display: inline-block;
        vertical-align: top;
    }

    #link-list-container table td:nth-child(4) { /* 설명 */
        display: block; /* 설명은 항상 블록으로 */
        margin-top: 8px;
        /* 액션 버튼이 있을 때와 없을 때를 구분하여 하단 마진 조정 */
        /* 이 부분은 JavaScript로 클래스를 추가하여 제어하거나,
           :has() 선택자를 지원하는 브라우저에서는 CSS로 가능하나,
           여기서는 일단 기본 마진을 설정하고, 액션 버튼이 있을 경우를 고려합니다. */
        margin-bottom: 30px; /* 기본 하단 마진 */
        padding-left: 0;
    }
     #link-list-container table td:nth-child(4)::before {
        display: none;
    }

    /* 액션 버튼 컨테이너 (로그인 상태일 때만 존재) */
    /* 만약 app.js에서 tr에 'has-actions' 클래스를 추가했다면, 아래 선택자를 사용하는 것이 더 좋습니다. */
    /* #link-list-container table tr.has-actions td:last-child { */
    #link-list-container table td:nth-child(5) { /* 또는 td:last-child */
        position: absolute;
        bottom: 10px;
        right: 10px;
        border: none;
        padding: 0;
        /* 이 셀은 wrapper의 위치만 잡고, 내부 정렬은 wrapper가 담당 */
    }
    #link-list-container .action-buttons-wrapper { /* 새로 추가된 wrapper 클래스 */
        display: flex;
        align-items: center;
        justify-content: flex-end; /* 버튼들을 우측으로 정렬 */
        width: 100%; /* wrapper가 셀의 전체 너비를 사용하도록 */
    }

    /* 만약 app.js에서 tr에 'has-actions' 클래스를 추가했다면,
       설명 셀의 하단 마진도 해당 클래스를 사용하여 조정해야 합니다. */
    #link-list-container table tr.has-actions td:nth-child(4) { /* 설명 셀 */
        margin-bottom: 45px; /* 액션 버튼과 겹치지 않도록 충분한 마진 */
    }

    /* 모바일에서 아이콘 버튼 스타일을 특별히 다르게 할 필요가 없다면,
       위에서 전역으로 옮긴 스타일이 그대로 적용됩니다.
       만약 모바일에서만 다른 크기나 여백을 주고 싶다면 여기에 추가합니다. */
}