@import "bootstrap.less";
@import (reference) "mixins.less";
@import "bootstrap-tokenfield.less";

// Bootstrap overrides
// @font-size-base: 16px;
@font-family-base: "Roboto";

// Custom variables
@header-height: 48px;
@box-height: 32px;
@highlight-on-bottom: inset 0 -16px 16px -16px @highlight-on-bg;
@highlight-on-top: inset 0 16px 16px -16px @highlight-on-bg;

// MIRC Colors
@mirc-color-0: #fff;
@mirc-color-1: #000;
@mirc-color-2: #0A0A85;
@mirc-color-3: #0f0;
@mirc-color-4: #f00;
@mirc-color-5: #800000;
@mirc-color-6: #800080;
@mirc-color-7: #808000;
@mirc-color-8: #FFFF00;
@mirc-color-9: #BFFF00;
@mirc-color-10: #008080;
@mirc-color-11: #00FFFF;
@mirc-color-12: #4169E1;
@mirc-color-13: #F984EF;
@mirc-color-14: #888;
@mirc-color-15: #d2d2d2;

body {
    overflow: hidden;
}

html, body, .container {
    height: 100%;
}

.panel-heading-small {
    padding: 0;
    .transition(background-color 0.2s ease-in-out;);
}

.btn-transparent {
    background-color: transparent !important;
    box-shadow: none !important;
}

.fill {
    width: 100%;
}

#container {
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    align-items: stretch;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.logged {
    display: flex;
    flex: 1;
    align-items: stretch;
    min-height: 0;
}

.buffer-container {
    overflow: auto;
    position: absolute;
    top: 0;
    width: 100%;
    bottom: @box-height;
}

.pane {
    position: relative;
    overflow: auto;
    font-family: @pane-font;
    color: @pane-color;
    background-color: @pane-bg;
    width: 16.6667%;
}

#buffer-pane.small {
    margin-left: ~"calc(-16.6667% + 32px)";
}

#nick-pane.small {
    margin-right: ~"calc(-16.6667% + 32px)";
}

.pane.small .buffer-container {
    opacity: 0;
}

.animation, .animation .network, .animation .network-channels {
    .transition(margin 0.5s ease-in-out, height 0.5s ease-in-out;);
}

.buffer-container  {
    .transition(opacity 0.5s linear, box-shadow 0.2s ease-in-out;);
}

.buffer-container.highlight-on-bottom {
    box-shadow: @highlight-on-bottom;
}

.buffer-container.highlight-on-top {
    box-shadow: @highlight-on-top;
}

.buffer-container.highlight-on-bottom.highlight-on-top {
    box-shadow: @highlight-on-bottom, @highlight-on-top;
}

#center {
    font-size: 15px;
    display: flex;
    flex: 1;
    flex-direction: column;
    position: relative;
    min-width: 0px;
}

.topic {
    height: 32px;
    line-height: 24px;
    min-height: 32px;
    overflow: visible;
    text-overflow: ellipsis;
    position: relative;
    background-color: @topic-bg;
}

#topic {
    font-family: @backlog-font;
    padding-left: 4px;
    padding-right: 36px;
    height: 32px;
    color: @topic-color;
    background-color: @topic-bg;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: 5px;
    padding-bottom: 5px;
}

#topic:hover {
    position: absolute;
    z-index: 1;
    height: auto;
    white-space: normal;
}

#header {
    background-color: @header-bg;
    color: @header-color;
    height: @header-height;
    line-height: @header-height;
    .transition(background-color 0.5s linear;);
}

#header small {
    opacity: 0.8;
}

.disconnected #header {
    background-color: @brand-warning;
}

.connecting #header {
    background-color: lighten(@brand-primary, 10%);
}

.network, .channel, .user {
    height: 32px;
    cursor: default;
    white-space: nowrap;
    display: flex;
    position: relative;

    &:hover, &.active {
        background-color: darken(@pane-bg, 5%);
    }
}

.network.off > span, .network.off + .network-channels .channel > .channel-name {
    opacity: 0.5;
}

.network-name, .group-name, .user-name, .channel-name {
    height: 32px;
    line-height: 32px;
    opacity: 0.75;
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
}

.network-name, .group-name {
    text-transform: uppercase;
}

.user-name {
    display: inline-block;
}

.collapsable {
    .icon;
    opacity: 0.5;
    cursor: pointer;
    padding: 4px;
    text-align: center;
}

.network-channels {
    display: block;
}

.network-channels.collapse:not(.in) {
    overflow: hidden;
}

.group-users {
    display: block;
    overflow: visible;
}

.user-icon {
    .icon;
    display: inline-block;
    float: left;
    padding: 5px;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.channel.selected {
    font-weight: normal;
}

.channel.selected.on .channel-name {
    opacity: 1;
}

.user-away {
    color: grey;
}

.user-not-away {
    color: green;
}

.user-owner:before {
    content: '~ ';
    font-size: 0.9em;
}

.user-admin:before {
    content: '& ';
    font-size: 0.9em;
}

.user-voiced:before {
    content: '\e806 ';
    font-size: 0.9em;
    font-family: "quassel-webserver";
    position: relative;
    top: 2px;
    display: inline-block;
    padding-right: 5px;
    line-height: 1;
}

.user-op:before {
    content: '@ ';
    font-size: 0.9em;
}

.user-half-op:before {
    content: '% ';
    font-size: 0.9em;
}

.channel-icon {
    .icon;
    display: inline-block;
    padding: 6px;
}

.buffer-bottom-bar {
    min-height: 32px;
    display: inline-block;
    bottom: 0;
    position: absolute;
    width: 100%;
    background-color: darken(@pane-bg, 5%);
}

.showhide {
    width: 32px;
    height: 32px;
    display: block;
    position: absolute;
    cursor: pointer;
    opacity: 0.5;
    padding: 6px;
    color: @pane-color;
    border-radius: 0;
    box-sizing: border-box;

    &:hover {
        opacity: 1;
        background-color: lighten(@pane-bg, 10%);
        border-left: 1px solid @pane-bg;
        border-right: 1px solid @pane-bg;
    }
    
    &.left {
        left: 0;
    }
    
    &.right {
        right: 0;
    }
    
    .icon-qws {
        font-size: 1.2em;
    }
}

.hidden-status:before {
    content: '\e801';  // eye open
}
.hidden-status.perm:before {
    opacity: 0.5;
    content: '\e802';  // eye close
}
.hidden-status.temp:before {
    content: '\e802';  // eye close
}

.quassel-logo {
    width: 24px;
    height: 24px;
    margin-left: 12px;
    margin-right: 8px;
    vertical-align: text-bottom;
    display: inline-block;
    background-image: url(../images/quassel-logo.png);
}

.quassel-logo.mini {
    width: 18px;
    height: 18px;
    margin-left: 0;
    background-size: 18px 18px;
}

.icon-secure {
    margin-left: 0.5em;
}

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

.connecting .quassel-logo {
    .animation(spin 1s linear infinite);
}

.dropdown-channel, .dropdown-user, .dropdown-network {
    .icon;
    opacity: 0.5;
    cursor: pointer;

    &:hover {
        opacity: 1;
    }
}

.dropdown-channel, .dropdown-user {
    display: none;
}

.channel:hover .dropdown-channel, .user:hover .dropdown-user, .dropdown-network {
    display: inline-block;
}

.input {
    width: 100%;
    background: @input-bg;
    word-break: break-word;
}

.input form {
    display: flex;
    flex: 1;
    flex-direction: row;
}

#messagebox {
    flex: 1;
    border: 0;
    padding: 5px 8px;
    outline: none;
    min-height: @box-height;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-width: 1px;
}

[contenteditable]:empty:not(:focus):before{
    content: attr(placeholder);
    color: gray;
    position: relative;
    cursor: text;
}

.input .formatter {
    min-height: @box-height;
    display: flex;

    .formatter-content {
        display: flex;
    }

    .btn {
        border-radius: 0;
    }

    .formatter-color .list-group-item {
        width: 410px;
    }

    ul {
        padding: 0 !important;
    }
}

.backlog {
    margin: 0;
    padding: 4px;
    border-spacing: 0;
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: @body-bg;
}

.backlog .timestamp > span {
    padding-right: 8px;
    padding-left: 4px;
    font-size: 14px;
    opacity: 0.5;
}

.backlog .nick {
    white-space: nowrap;
    padding-right: 8px;
    font-weight: 400;
    text-align: right;
}

.backlog .message {
    word-wrap: break-word;
    .word-break-all;
    width: 100%;
    font-size: 0.85em;
    white-space: pre-wrap;
}

.backlog .irc-message {
    display: table-row;
}

.backlog .irc-message > * {
    display: table-cell;
}

.backlog .irc-embed-label {
    margin-left: 4px;
    
    &:hover {
        background-color: @label-primary-bg;
    }
}

.backlog .markerline {
    height: 1px;
    background-color: @markerline-bg;
}

.backlog .markerline:last-child {
    display: none;
}

.fetching {
    display: inherit;
    text-align: center;
    top: 32px;
    position: absolute;
    right: 0;
    padding: 2px 7px;
    background-color: lighten(@brand-primary, 25%);
    color: white;
}

.splash, .login-container {
    padding: 16px;
    margin: 16px;
    margin-top: 64px;
}

.logout, .reconnect, .config {
    float: right;
    margin: 7px;
}

.prefs .dropdown-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    opacity: 0.4;
    z-index: 10;
    padding: 3px 7px;
    font-size: 1em;
    cursor: pointer;

    &:hover {
        opacity: 0.8;
    }
}

.prefs .dropdown-menu {
    position: relative;
    top: 30px;
}

.prefs {
    right: 0;
    top: 0;
    position: absolute;
}

.prefs .dropdown-menu > li label {
    font-weight: inherit;
    text-transform: inherit;
    padding: 0 5px;
    cursor: pointer;
}

.prefs .dropdown-menu > li > a {
    padding: 3px 30px;
}

.prefs .dropdown-menu .checkbox {
    margin-top: 2px;
    margin-bottom: 2px;
}

[draggable] {
    user-select: none;
}

.drag.dragging {
    opacity: 0.7;
}

input[type="number"] {
    max-width: 100px;
}

// MIRC colors
.loop-mirc-color(@counter) when (@counter >= 0) {
  .loop-mirc-color((@counter - 1));
  .mirc-fg-@{counter} {
    color: ~'@{mirc-color-@{counter}}';
  }
  .mirc-bg-@{counter} {
    background-color: ~'@{mirc-color-@{counter}}';
  }
}
.loop-mirc-color(15);

.mirc-bold {font-weight: bold;}
.mirc-italic {font-style: italic;}
.mirc-underline {text-decoration:underline !important;}

.mirc-bg-transparent {background-color:transparent;}

// Notifications
.cg-notify-message {
    position: fixed;
    left: 50%;
    top: 0px;
    z-index: 9999;
    max-width: 400px;
    text-align: center;
    font-size: 14px;
    padding: 10px 15px 10px 10px;

    background-color: @state-info-bg;
    color: @state-info-text;
    border: 1px solid @state-info-border;

    transition: top 0.5s ease-out,opacity 0.2s ease-out;

    visibility: hidden;
}

.cg-notify-message a {
    font-weight: bold;
    color: inherit;

    &:hover {
        color: inherit;
    }
}

.cg-notify-message.alert-warning {
    background-color: @state-warning-bg;
    color: @state-warning-text;
    border: 1px solid @state-warning-border;
}

.cg-notify-message.alert-danger {
    background-color: @state-danger-bg;
    color: @state-danger-text;
    border: 1px solid @state-danger-border;
}

.cg-notify-close {
    -webkit-appearance: none;
    padding: 0;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;

    position: absolute;
    top: 0px;
    right: 3px;
    line-height: 15px;

    background: 0 0;
    border: 0;
    color: black;
    text-shadow: 0 1px 0 #fff;
    opacity: .2;
}

.cg-notify-close:hover, .cg-notify-close:focus {
    text-decoration: none;
    cursor: pointer;
    color: black;
    opacity: .5;
}

.cg-notify-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

.channel.selected {
    background-color: black;
}

.buffer-highlight-low {
    .channel-name, .network-name {
        color: @highlight-low-color;
        opacity: 1;
    }
}

.buffer-highlight-medium {
    .channel-name, .network-name {
        color: @highlight-medium-color;
        opacity: 1;
    }
}

.buffer-highlight-high {
    .channel-name, .network-name {
        color: @highlight-high-color;
        opacity: 1;
    }
}

.dropdown-network .icon-qws, .dropdown-channel .icon-qws, .dropdown-user .icon-qws {
    color: @pane-color;
    top: 6px;
    left: 5px;
    font-size: 1.3em;
}

.network .dropdown-menu li, .network-channels .dropdown-menu li:not(.dropdown-header) {
    color: black;
}

.backlog .timestamp > span, .backlog .message, .backlog .nick {
    font-family: @backlog-font;
}

.backlog .irc-message.highlighted {
    background-color: @highlight-message-bg;
}

.drop.dropable.hover {
    box-shadow: inset 0 0 8px #000;
}

// Tabs

.tab-margin .tab-pane {
    margin: 15px 15px;
}

// Minimum width for the sidebars.
#buffer-pane:not(.small),
#nick-pane:not(.small) {
    min-width: 240px;
}

@media (max-width: 767px) {
    // Overlay the sidebars over the backlog.
    .pane {
        position: absolute;
        top: 48px;
        bottom: 32px;
        right: 10px;
        z-index: 20;
        box-shadow: 10px 0 10px -5px #000;

        .buffer-container {
            height: ~"calc(100% - 32px)";
            position: static;
        }

        // Only show the expand button when sidebar is collapsed.
        &.small {
            background: none;
            box-shadow: none;
            height: 32px;
            top: initial;

            .buffer-container {
                display: none;
            }

            .buffer-bottom-bar {
                opacity: .25;

                &:hover {
                    opacity: 1;
                }
            }
        }
    }
    #buffer-pane {
        left: 0;
        box-shadow: 10px 0 10px -5px #000;
    }
    #nick-pane {
        right: 0;
        box-shadow: -10px 0 10px -5px #000;
    }
    
    .backlog {
        .irc-message > .timestamp {
            display: table-cell;
            
            > span {
                padding-right: 6px;
                padding-left: 1px;
                font-size: 0.8em;
                font-family: "Roboto";
            }
        }
        
        .irc-message > .nick, .irc-message > .message {
            display: inline;
        }
    }
    
    .dropdown-channel, .dropdown-user {
        display: inline-block;
    }
}

// Aliases
.form-alias .table input[type="text"]:not(:hover):not(:active):not(:focus):not(.ng-invalid) {
    background-color: transparent;
    border-color: transparent;
}

.form-alias .panel .panel-body {
    padding: 5px;
}

// Scrollbars customization
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
    transition: box-shadow 400ms;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

::-webkit-scrollbar-track:hover {
    box-shadow: inset 0 0 6px 1px rgba(0,0,0,0.3);
}

::-webkit-scrollbar-thumb {
    border-radius: 4px;
    box-shadow: inset 0 0 6px 1px rgba(0,0,0,0.5);
}

// Errors
.ng-invalid {
  &.help-block,
  &.control-label,
  &.radio,
  &.checkbox,
  &.radio-inline,
  &.checkbox-inline,
  &.form-control-feedback {
    color: @brand-danger;
  }

  &.form-control,
  &.form-control:focus {
    border-color: @brand-danger;
  }

  &.input-group-addon {
    background-color: @gray-dark;
    border-color: @input-group-addon-border-color;
  }
}

input[type="radio"]:disabled ~ span, input[type="checkbox"]:disabled ~ span {
  opacity: 0.5;
}

// Message styles
.type-1 { .nick,.message {color: @type-1-color;}} // Plain
.type-2 { .nick,.message {color: @type-2-color;}} // Notice
.type-4 { .nick,.message {color: @type-4-color;}} // Action
.type-8 { .nick,.message {color: @type-8-color;}} // Nick
.type-16 { .nick,.message {color: @type-16-color;}} // Mode
.type-32 { .nick,.message {color: @type-32-color;}} // Join
.type-64 { .nick,.message {color: @type-64-color;}} // Part
.type-128 { .nick,.message {color: @type-128-color;}} // Quit
.type-256 { .nick,.message {color: @type-256-color;}} // Kick
.type-512 { .nick,.message {color: @type-512-color;}} // Kill
.type-1024 { .nick,.message {color: @type-1024-color;}} // Server
.type-2048 { .nick,.message {color: @type-2048-color;}} // Info
.type-4096 { .nick,.message {color: @type-4096-color;}} // Error
.type-8192 { .nick,.message {color: @type-8192-color;}} // DayChange
.type-16384 { .nick,.message {color: @type-16384-color;}} // Topic
.type-32768 { .nick,.message {color: @type-32768-color;}} // NetsplitJoin
.type-65536 { .nick,.message {color: @type-65536-color;}} // NetsplitQuit
.type-131072 { .nick,.message {color: @type-131072-color;}} // Invite

// Colorize nicks
[ng-nick][data-nickhash="0"], .nick[data-nickhash="0"] { color: @nichkash-0-color; }
[ng-nick][data-nickhash="1"], .nick[data-nickhash="1"] { color: @nichkash-1-color; }
[ng-nick][data-nickhash="2"], .nick[data-nickhash="2"] { color: @nichkash-2-color; }
[ng-nick][data-nickhash="3"], .nick[data-nickhash="3"] { color: @nichkash-3-color; }
[ng-nick][data-nickhash="4"], .nick[data-nickhash="4"] { color: @nichkash-4-color; }
[ng-nick][data-nickhash="5"], .nick[data-nickhash="5"] { color: @nichkash-5-color; }
[ng-nick][data-nickhash="6"], .nick[data-nickhash="6"] { color: @nichkash-6-color; }
[ng-nick][data-nickhash="7"], .nick[data-nickhash="7"] { color: @nichkash-7-color; }
[ng-nick][data-nickhash="8"], .nick[data-nickhash="8"] { color: @nichkash-8-color; }
[ng-nick][data-nickhash="9"], .nick[data-nickhash="9"] { color: @nichkash-9-color; }
[ng-nick][data-nickhash="10"], .nick[data-nickhash="10"] { color: @nichkash-10-color; }
[ng-nick][data-nickhash="11"], .nick[data-nickhash="11"] { color: @nichkash-11-color; }
[ng-nick][data-nickhash="12"], .nick[data-nickhash="12"] { color: @nichkash-12-color; }
[ng-nick][data-nickhash="13"], .nick[data-nickhash="13"] { color: @nichkash-13-color; }
[ng-nick][data-nickhash="14"], .nick[data-nickhash="14"] { color: @nichkash-14-color; }
[ng-nick][data-nickhash="15"], .nick[data-nickhash="15"] { color: @nichkash-15-color; }
[ng-nick][data-nickhash] { font-weight: bold; }

// Colorpicker
colorpicker .colors li {
  display: inline-block;
  padding: 0;
  margin: 2px;
  box-shadow: 0 0 1px white;
  border-radius: 50%;
}

colorpicker .colors li:hover {
  opacity: 0.5;
}

colorpicker .colors .btn {
  display: inline-block;
  width: 21px;
  height: 21px;
  border-radius: inherit !important;
}

// Loader
.loader {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loader .quassel-logo {
  .animation(spin 1s linear infinite);
}

// Embed
.irc-embed {
  width: 100%;
  padding: 5px;
  border: 1px solid #e4e4e4;
  border-radius: 2px;
  margin: 5px 0;
  box-shadow: 0px 1px 1px 0 rgba(0, 0, 0, 0.26);
  border-bottom: 0;
  padding-bottom: 1px;
  
  .row {
    margin-left: 0;
    margin-right: 0;
  }
  
  .close {
    margin: 2px 7px 10px 0;
  }
  
  small:first-letter{
    text-transform: capitalize;
    opacity: 0.6;
  }
}

.embed {
  clear: left;
}

.embed.audio {
  background-color: #1D1D1D;
  padding-top: 6px;
  
  audio {
    width: 100%;
  }
}

.embed.video {
  border-bottom: 0;
  overflow: auto;
  transition: all 0.5s linear;
}

.embed.video video,
.embed.video object,
.embed iframe {
  width: 100%;
  border: 0;
}

.embed.image {
  max-height: 999px;
  overflow: auto;
  padding-bottom: 5px;
  margin: 10px 0;

  img {
    max-width: 100%;
    display: block;
  }
}
