/* General Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Variables */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f7fa;
    --dark-color: #2c3e50;
    --light-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e6ed;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--secondary-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

a {
    text-decoration: none;
    color: var(--primary-color);
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar Navigation */
.sidebar {
    width: 240px;
    background-color: var(--dark-color);
    color: var(--light-color);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 0 20px 20px 20px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #4a5a6a;
}

.sidebar-nav {
    list-style: none;
    margin-top: 20px;
    flex-grow: 1;
}

.sidebar-nav li a {
    display: block;
    color: var(--light-color);
    padding: 15px 20px;
    transition: background-color 0.3s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background-color: #4a5a6a;
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    font-size: 0.8rem;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2rem;
    color: var(--dark-color);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.3s;
}

.btn:hover {
    opacity: 0.8;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--light-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--light-color);
}

/* Table */
.content-card {
    background-color: var(--light-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--secondary-color);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Custom styles for highlighting bound sub-links */
.bound-link {
    background-color: #e8f5e9; /* A light green color */
}

.bound-link:hover {
    background-color: #dcedc8; /* A slightly darker green on hover */
}

td .btn {
    padding: 5px 10px;
    margin-right: 5px;
    font-size: 0.9rem;
}

/* Modal */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--light-color);
    margin: auto;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: var(--dark-color);
}

.close-btn {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
}

.form-actions {
    margin-top: 30px;
    text-align: right;
}

#searchForm,
#search-user-form,
#subLinkSearchForm,
#visitor-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

#searchForm .btn,
#search-user-form .btn,
#subLinkSearchForm .btn,
#visitor-search-form .btn {
    padding-left: 28px;
    padding-right: 28px;
}

#searchForm .form-control,
#search-user-form .form-control,
#visitor-search-form .form-control {
    width: 250px;
}

#subLinkSearchForm .form-control {
    width: 220px;
}

.truncate-cell {
    max-width: 200px; /* Default for PC */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Login Page Specifics */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    background-color: var(--secondary-color);
}

.login-box {
    background: var(--light-color);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 30px;
    color: var(--dark-color);
}

.login-box .form-group {
    text-align: left;
}

.login-box .btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

/* System Page Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}
.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px; /* Overlap the container border */
}
.tab-link.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fade-in 0.5s;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
}
.page-btn {
    background-color: var(--light-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 12px;
}
.page-btn.active {
    background-color: var(--primary-color);
    color: var(--light-color);
    border-color: var(--primary-color);
}
.page-btn:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}
.page-ellipsis {
    padding: 0 10px;
    align-self: center;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 15px 20px;
    border-radius: 5px;
    color: var(--light-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateX(100%);
    animation: slide-in 0.5s forwards, fade-out 0.5s 4s forwards;
}

.toast.toast-success {
    background-color: var(--success-color);
}

.toast.toast-error {
    background-color: var(--danger-color);
}

@keyframes slide-in {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Current Sub-link Styling */
.current-sub-link-row {
    background-color: #e0f7fa; /* Light cyan for current row */
    font-weight: bold;
}

.btn-current {
    background-color: #007bff; /* Primary blue for current button */
    color: white;
    border: 1px solid #007bff;
    cursor: default;
}

.btn-current:hover {
    background-color: #1e8449;
    border-color: #1e8449;
}

/* Form Styles */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }
    
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 15px 0;
    }
    
    .sidebar-header {
        padding: 0 20px 15px 20px;
    }
    
    .sidebar-nav {
        margin-top: 10px;
    }

    .main-content {
        padding: 20px;
        overflow-y: visible;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    #searchForm,
    #search-user-form,
    #subLinkSearchForm,
    #visitor-search-form {
        flex-direction: column;
        align-items: stretch;
    }

    #searchForm .form-control,
    #search-user-form .form-control,
    #subLinkSearchForm .form-control,
    #visitor-search-form .form-control {
        width: 100%;
    }

    .truncate-cell {
        max-width: 100px; /* Smaller for mobile */
    }

    th, td {
        padding: 10px;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }

    .login-box {
        width: 90%;
        margin: 20px auto;
        padding: 30px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .sublink-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
}

/* Header actions alignment */
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px; /* Space between items */
}

/* Task Toggle Switch */
.task-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.task-status-label, .status-running, .status-stopped, .status-unknown {
    font-size: 14px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.status-running {
    color: #28a745;
    background-color: #e9f7ec;
}

.status-stopped {
    color: #dc3545;
    background-color: #fdeaea;
}

.status-unknown {
    color: #909399;
}

.status-abnormal {
    color: var(--danger-color);
    font-weight: bold;
}

/* General Switch styles */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked + .slider {
    background-color: #28a745;
}

input:focus + .slider {
    box-shadow: 0 0 1px #28a745;
}

input:checked + .slider:before {
    -webkit-transform: translateX(22px);
    -ms-transform: translateX(22px);
    transform: translateX(22px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
} 
