
/* =====================================================
   ISP Management System - Custom Stylesheet
   ===================================================== */

/* CSS Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #1abc9c;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
    --dark-color: #1a252f;
    --light-color: #f8f9fa;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --transition-speed: 0.3s;
    --border-radius: 10px;
    --box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    --box-shadow-hover: 0 8px 25px rgba(0,0,0,0.12);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--dark-color) 100%);
    color: white;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: all var(--transition-speed) ease;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

.sidebar-brand {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
}

.sidebar-brand h4 {
    margin: 0;
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
}

.sidebar-brand small {
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-user {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.nav-link {
    color: rgba(255,255,255,0.75) !important;
    padding: 14px 22px !important;
    border-radius: 0;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    position: relative;
    border-left: 4px solid transparent;
}

.nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: white !important;
    border-left-color: var(--secondary-color);
    padding-left: 26px !important;
}

.nav-link.active {
    background: rgba(255,255,255,0.12);
    color: white !important;
    border-left-color: var(--accent-color);
    font-weight: 500;
}

.nav-link i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.nav-link:hover i {
    transform: scale(1.1);
}

.nav-badge {
    margin-left: auto;
    background: var(--danger-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 25px;
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
}

/* Topbar */
.topbar {
    background: white;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h5 {
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-bell {
    position: relative;
    color: #666;
    transition: color 0.2s;
    text-decoration: none;
}

.notification-bell:hover {
    color: var(--secondary-color);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.user-dropdown .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.user-dropdown .avatar:hover {
    transform: scale(1.05);
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: all 0.3s ease;
    background: white;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--box-shadow-hover);
}

.card-header {
    background: white;
    border-bottom: 1px solid #f0f0f0;
    padding: 18px 25px;
    font-weight: 600;
}

.card-header h5, .card-header h6 {
    margin: 0;
    color: var(--primary-color);
}

.card-body {
    padding: 25px;
}

/* Stat Cards */
.stat-card {
    padding: 25px;
    border-radius: var(--border-radius);
    color: white;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    transition: all 0.5s ease;
}

.stat-card:hover::before {
    transform: scale(1.2);
}

.stat-card i {
    font-size: 3rem;
    opacity: 0.2;
    position: absolute;
    right: 20px;
    top: 20px;
    transition: all 0.3s ease;
}

.stat-card:hover i {
    opacity: 0.3;
    transform: scale(1.1) rotate(5deg);
}

.stat-card .number {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 5px;
    position: relative;
    z-index: 1;
}

.stat-card .label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.stat-card .trend {
    font-size: 0.8rem;
    margin-top: 10px;
    opacity: 0.8;
    position: relative;
    z-index: 1;
}

/* Gradient Backgrounds */
.bg-primary-gradient { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
}
.bg-success-gradient { 
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); 
}
.bg-warning-gradient { 
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); 
}
.bg-danger-gradient { 
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); 
}
.bg-info-gradient { 
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); 
}
.bg-dark-gradient { 
    background: linear-gradient(135deg, #434343 0%, #000000 100%); 
}

/* Badges & Status */
.badge-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
}

.status-active { background: #d4edda; color: #155724; }
.status-inactive { background: #f8d7da; color: #721c24; }
.status-suspended { background: #fff3cd; color: #856404; }
.status-terminated { background: #e2e3e5; color: #383d41; }
.status-open { background: #d1ecf1; color: #0c5460; }
.status-in_progress { background: #cce5ff; color: #004085; }
.status-resolved { background: #d4edda; color: #155724; }
.status-closed { background: #e2e3e5; color: #383d41; }
.status-escalated { background: #f8d7da; color: #721c24; }
.status-urgent { background: #f8d7da; color: #721c24; }
.status-faulty { background: #f5c6cb; color: #721c24; }
.status-reserved { background: #d6d8db; color: #383d41; }

/* Profit/Loss */
.profit-positive { 
    color: var(--success-color); 
    font-weight: 700; 
}
.profit-negative { 
    color: var(--danger-color); 
    font-weight: 700; 
}
.profit-neutral { 
    color: #6c757d; 
    font-weight: 700; 
}

/* Tables */
.table {
    font-size: 0.9rem;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    color: #666;
    border-bottom: 2px solid #e9ecef;
    padding: 15px;
}

.table tbody td {
    padding: 15px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-actions {
    white-space: nowrap;
}

.table-actions .btn {
    padding: 5px 10px;
    font-size: 0.8rem;
    margin: 0 2px;
    border-radius: 6px;
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    padding: 6px 12px !important;
    margin: 0 2px !important;
    border: none !important;
    background: #f0f0f0 !important;
    color: #666 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--secondary-color) !important;
    color: white !important;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 10px 20px;
    transition: all 0.25s ease;
    border: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color), #2980b9);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #229954);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #c0392b);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #e67e22);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color), #138496);
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--secondary-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* Forms */
.form-control, .form-select {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 0.95rem;
    transition: all 0.25s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.input-group-text {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px 0 0 8px;
    color: #666;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    padding: 20px 25px;
}

.modal-header .btn-close {
    filter: invert(1);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #f0f0f0;
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 15px 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--info-color);
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}

.chat-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: white;
    border: none;
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.5);
}

.chat-btn.pulse {
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(52, 152, 219, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
}

.chat-panel {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transition: all 0.3s ease;
    transform: translateY(20px);
    opacity: 0;
}

.chat-panel.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header .status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header .status-dot {
    width: 10px;
    height: 10px;
    background: #2ecc71;
    border-radius: 50%;
    animation: blink 2s infinite;
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
}

.chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    background: white;
}

.chat-input-area input {
    border-radius: 25px;
    padding: 12px 20px;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.chat-input-area input:focus {
    background: white;
    border-color: var(--secondary-color);
}

.chat-input-area button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-bubble {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-client {
    background: linear-gradient(135deg, var(--secondary-color), #2980b9);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

.message-bot {
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 5px;
    display: block;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    align-self: flex-start;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Switch Port Grid */
.port-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.port-card {
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.port-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.port-card.active {
    border: 2px solid var(--success-color);
    background: #f0fff4;
}

.port-card.inactive {
    border: 2px solid #e0e0e0;
    background: #fafafa;
}

.port-card.faulty {
    border: 2px solid var(--danger-color);
    background: #fff5f5;
}

.port-card.reserved {
    border: 2px solid var(--warning-color);
    background: #fffbeb;
}

.port-number {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.port-status {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.port-client {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
    width: 100%;
    max-width: 450px;
}

.login-card .card-body {
    padding: 40px;
}

.login-logo {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
    font-size: 2.5rem;
    color: white;
    box-shadow: 0 10px 30px rgba(52, 152, 219, 0.3);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease forwards;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress Bars */
.progress {
    height: 8px;
    border-radius: 10px;
    background: #e9ecef;
    overflow: hidden;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.6s ease;
}

/* Timeline for Tickets */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e0e0e0;
}

.timeline-item {
    position: relative;
    padding-bottom: 25px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary-color);
    border: 3px solid white;
    box-shadow: 0 0 0 3px #e0e0e0;
}

.timeline-item.completed::before {
    background: var(--success-color);
    box-shadow: 0 0 0 3px #d4edda;
}

.timeline-content {
    background: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .chat-panel {
        width: 100%;
        right: 0;
        bottom: 0;
        height: 100vh;
        border-radius: 0;
    }
}

@media (max-width: 768px) {
    .stat-card .number {
        font-size: 1.6rem;
    }

    .port-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .topbar {
        padding: 12px 15px;
    }

    .main-content {
        padding: 15px;
    }
}

/* Print Styles */
@media print {
    .sidebar, .chat-widget, .topbar, .btn, .table-actions {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        background: #1a1a2e;
        color: #e0e0e0;
    }

    body:not(.light-mode) .card {
        background: #16213e;
        color: #e0e0e0;
    }

    body:not(.light-mode) .card-header {
        background: #16213e;
        border-color: #2a2a4a;
    }

    body:not(.light-mode) .table thead th {
        background: #1a1a2e;
        color: #aaa;
        border-color: #2a2a4a;
    }

    body:not(.light-mode) .form-control,
    body:not(.light-mode) .form-select {
        background: #16213e;
        border-color: #2a2a4a;
        color: #e0e0e0;
    }
}
